Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 为什么我的扩展容器没有占据设备的剩余高度?_Flutter_Dart - Fatal编程技术网

Flutter 为什么我的扩展容器没有占据设备的剩余高度?

Flutter 为什么我的扩展容器没有占据设备的剩余高度?,flutter,dart,Flutter,Dart,我遵循本教程,遇到了一个问题。我有一个主容器,主容器中有一列。在列内部,有各种元素,最后有一个扩展容器,可以创建重叠效果。但是,问题是扩展容器没有覆盖设备高度的其余部分,并且在靠近末端的地方留有一个空间,显示父容器的背景。我是一个新手,所以我现在正在学习语法,我试着将扩展容器的高度增加一倍,但没有成功。我怎样才能解决这个问题 导入“包装:颤振/材料.省道”; 类LoginScreen扩展StatefulWidget{ @凌驾 _LoginsScreenState createState()=>

我遵循本教程,遇到了一个问题。我有一个主容器,主容器中有一列。在列内部,有各种元素,最后有一个扩展容器,可以创建重叠效果。但是,问题是扩展容器没有覆盖设备高度的其余部分,并且在靠近末端的地方留有一个空间,显示父容器的背景。我是一个新手,所以我现在正在学习语法,我试着将扩展容器的高度增加一倍,但没有成功。我怎样才能解决这个问题

导入“包装:颤振/材料.省道”;
类LoginScreen扩展StatefulWidget{
@凌驾
_LoginsScreenState createState()=>\u LoginsScreenState();
}
类_LoginScreenState扩展状态{
@凌驾
小部件构建(构建上下文){
返回脚手架(
主体:容器(
填充:边缘设置。对称(垂直:30.0),
宽度:double.infinity,
装饰:盒子装饰(
梯度:线性梯度(
开始:Alignment.topCenter,
颜色:[
颜色。蓝色[900],
颜色。蓝色[500],
颜色。蓝色[400],
],
),
),
子:列(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
尺寸箱(高度:40.0),
填充物(
填充:边缘设置。全部(20),
子:列(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
正文(
“Eazy”,
样式:TextStyle(
颜色:颜色,白色,
字体大小:40.0,
fontWeight:fontWeight.w400,
),
),
正文(
“银行”,
样式:TextStyle(
颜色:颜色,白色,
字体大小:40.0,
fontWeight:fontWeight.w400,
),
),
],
),
),
大小盒子(
身高:10.0,
),
扩大(
子:容器(
装饰:盒子装饰(
颜色:颜色,白色,
borderRadius:仅限borderRadius(
左上:半径。圆形(60),
右上角:半径。圆形(60),
),
),
),
),
],
),
),
);
}
}

问题在于
填充:边缘设置。对称(垂直:30.0)
填充
在两个垂直方向(顶部和底部)的值均为
30.0逻辑像素

您可以通过使用
padding:EdgeInsets.only(top:30.0)
来修复此问题,它仅为容器的
top
提供填充

我以您的小部件树为例添加了一个演示:

import 'package:flutter/material.dart';

class LoginScreen extends StatefulWidget {
  @override
  _LoginScreenState createState() => _LoginScreenState();
}

class _LoginScreenState extends State<LoginScreen> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        padding: EdgeInsets.only(top: 30.0), // new line
        width: double.infinity,
        decoration: BoxDecoration(
          gradient: LinearGradient(
            begin: Alignment.topCenter,
            colors: [
              Colors.blue[900],
              Colors.blue[500],
              Colors.blue[400],
            ],
          ),
        ),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            SizedBox(height: 40.0),
            Padding(
              padding: EdgeInsets.all(20),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Text(
                    "Eazy",
                    style: TextStyle(
                      color: Colors.white,
                      fontSize: 40.0,
                      fontWeight: FontWeight.w400,
                    ),
                  ),
                  Text(
                    "Bank",
                    style: TextStyle(
                      color: Colors.white,
                      fontSize: 40.0,
                      fontWeight: FontWeight.w400,
                    ),
                  ),
                ],
              ),
            ),
            SizedBox(
              height: 10.0,
            ),
            Expanded(
              child: Container(
                decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(60),
                    topRight: Radius.circular(60),
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

导入“包装:颤振/材料.省道”;
类LoginScreen扩展StatefulWidget{
@凌驾
_LoginsScreenState createState()=>\u LoginsScreenState();
}
类_LoginScreenState扩展状态{
@凌驾
小部件构建(构建上下文){
返回脚手架(
主体:容器(
填充:EdgeInsets.only(顶部:30.0),//新行
宽度:double.infinity,
装饰:盒子装饰(
梯度:线性梯度(
开始:Alignment.topCenter,
颜色:[
颜色。蓝色[900],
颜色。蓝色[500],
颜色。蓝色[400],
],
),
),
子:列(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
尺寸箱(高度:40.0),
填充物(
填充:边缘设置。全部(20),
子:列(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
正文(
“Eazy”,
样式:TextStyle(
颜色:颜色,白色,
字体大小:40.0,
fontWeight:fontWeight.w400,
),
),
正文(
“银行”,
样式:TextStyle(
颜色:颜色,白色,
字体大小:40.0,
fontWeight:fontWeight.w400,
),
),
],
),
),
大小盒子(
身高:10.0,
),
扩大(
子:容器(
装饰:盒子装饰(
颜色:颜色,白色,
borderRadius:仅限borderRadius(
左上:半径。圆形(60),
右上角:半径。圆形(60),
),
),
),
),
],
),
),
);
}
}
import 'package:flutter/material.dart';

class LoginScreen extends StatefulWidget {
  @override
  _LoginScreenState createState() => _LoginScreenState();
}

class _LoginScreenState extends State<LoginScreen> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        padding: EdgeInsets.only(top: 30.0), // new line
        width: double.infinity,
        decoration: BoxDecoration(
          gradient: LinearGradient(
            begin: Alignment.topCenter,
            colors: [
              Colors.blue[900],
              Colors.blue[500],
              Colors.blue[400],
            ],
          ),
        ),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            SizedBox(height: 40.0),
            Padding(
              padding: EdgeInsets.all(20),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Text(
                    "Eazy",
                    style: TextStyle(
                      color: Colors.white,
                      fontSize: 40.0,
                      fontWeight: FontWeight.w400,
                    ),
                  ),
                  Text(
                    "Bank",
                    style: TextStyle(
                      color: Colors.white,
                      fontSize: 40.0,
                      fontWeight: FontWeight.w400,
                    ),
                  ),
                ],
              ),
            ),
            SizedBox(
              height: 10.0,
            ),
            Expanded(
              child: Container(
                decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(60),
                    topRight: Radius.circular(60),
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}