flutter - 为什么要扩大而不是扩大高度

标签 flutter dart flutter-layout

我是新来的 flutter 。寻求帮助。我想知道为什么我的扩展容器不能扩展到屏幕末端。

Widget build(BuildContext context) {
    return Scaffold(
  body:
    Container(
        color: Colors.white,
        child: Stack(
            children: <Widget>[
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisAlignment: MainAxisAlignment.start,
                mainAxisSize: MainAxisSize.min,
                children: <Widget>[
                  Container(
                  color: Colors.white,
                  height: 300.0,//350.0,
                  width: double.infinity,
                      child: Image.asset(
                  'Images/waves.png',
                  fit: BoxFit.fill,
                    ),
                    ),
                      SizedBox(height: 5,),
                    ],
                    ),

              Container(
                  child:FutureBuilder<Getdata>(
                future: fetchGetdata(),
                builder: (context, snapshot){
                  if (snapshot.hasData) {
                    String nama =snapshot.data.nama;
                    String program =snapshot.data.program;
                    String notel =snapshot.data.notel;
                    String cgpa =snapshot.data.cgpa;
                    return Container(
                      padding: EdgeInsets.all(15.0),
                      child:Column(
                                          mainAxisAlignment: MainAxisAlignment.start,
                                         crossAxisAlignment: CrossAxisAlignment.center,
                                          mainAxisSize: MainAxisSize.min,
                                          children: <Widget>[
                                            SizedBox(height:30),
                                            /*Stack(
                                              children: <Widget>[
                                                Container(
                                                   //color: Color.fromRGBO(240, 240, 255, 1),
                                                  decoration: BoxDecoration(
                                                    color: Color.fromRGBO(240, 216, 216, 1),
                                                    borderRadius: BorderRadius.only(
                                                        topLeft: Radius.circular(10),
                                                        topRight: Radius.circular(10),
                                                        bottomLeft: Radius.circular(10),
                                                        bottomRight: Radius.circular(10)
                                                    ),
                                                    boxShadow: [
                                                      BoxShadow(
                                                        color: Colors.grey.withOpacity(0.5),
                                                        spreadRadius: 3,
                                                        blurRadius: 5,
                                                        offset: Offset(0, 3), // changes position of shadow
                                                      ),
                                                    ],),),
                                                CircleAvatar(backgroundImage: AssetImage('Images/myresult.png', ), radius:50.0,),
                                              ],
                                            ),*/
                                            CircleAvatar(backgroundImage: AssetImage('Images/myresult.png', ), radius:50.0,),
                                            SizedBox(height:10),
                                            Flexible( child:Text('$nama', style: TextStyle(
                                                fontFamily: 'raleway',
                                                color: Colors.white,fontSize: 18), softWrap: true, textAlign: TextAlign.center ),),
                                            Flexible( child:Text('$program', style: TextStyle(
                                                fontFamily: 'raleway',
                                                color: Colors.white, fontSize: 9),softWrap: true, textAlign: TextAlign.center ),),
                                            SizedBox(height:50),
                                            Expanded(
                                              child: Container(
                                                child: ListView(
                                                  children: <Widget>[
                                                    ListTile(
                                                      leading: Icon(Icons.book, color: Colors.deepPurple,),
                                                      title:
                                                        Text('Program:', style: TextStyle(
                                                            fontFamily: 'raleway',
                                                            fontWeight: FontWeight.bold) ),
                                                      subtitle: Text('$program' ),
                                                    ),
                                                    ListTile(
                                                      leading: Icon(Icons.phone, color: Colors.blueAccent,),
                                                      title:
                                                        Text(' Telefon', style: TextStyle(
                                                            fontWeight: FontWeight.bold) ),
                                                      subtitle: Text('$notel'),
                                                    ),
                                                  ],

                                                ),
                                              ),
                                            ),

                                    ],

                                 ),



                              );



              
                            } else if (snapshot.hasError) {
                              return Text("${snapshot.error}");}
              
                            return CircularProgressIndicator();
              
                          }
    ),
  ),
    ])),

);

最佳答案

您的某些Columns已设置mainAxisSize: MainAxisSize.min,将其更改为MainAxisSize.max即可扩展它们,而不是包装内容。对于所有这些人可能都没有必要。

关于flutter - 为什么要扩大而不是扩大高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63355532/

相关文章:

Flutter Firebase 身份验证忽略 header X-Firebase-Locale,因为它的值为 null

dart - Flutter,如何让我的原 Material 纽扣更大更紧密地组合在一起。

dart - 如何解决运行 "flutter packages get"

oop - 如何在类构造函数参数中动态传递窗口小部件

flutter - 你如何在 dart 中使用抽象类进行继承?错误 : superclass SpanishData doesn't have a zero argument constructor

flutter - 无需每次调用​​ `of(context)` 的 AppLocalizations

flutter - 图片在上,文字在下的卡片

flutter - 无效的参数:URL文件:///Trousers中未指定主机

dart - 将 Widget 与 State 分开

ios - 在iOS上运行Flutter项目时出现重新定义错误