繁体   English   中英

底部溢出 23 个像素的 RenderFlex

[英]A RenderFlex overflowed by 23 pixels on the bottom

如何解决异常“A RenderFlex 在底部溢出 23 个像素”。 在我的应用程序中,我创建了 Gridview。 但是每次运行代码时都会获得 RenderFlex。 我用扩展添加包装 Gridview

  1. 滚动方向:Axis.vertical,
  2. 收缩包装:是的,

但仍然没有效果得到这个异常。 谁能纠正我; 我在我的代码中做错了什么? 我应该怎么做。

这是我收到错误的代码:

Widget build(BuildContext context) {
    return Scaffold(
       body:Container(
            height: 150,
            width: MediaQuery.of(context).size.width,
            color: Colors.grey[100],
            child: Column(children: [
              Expanded(
                child: Padding(
                  padding: EdgeInsets.fromLTRB(10, 40, 0, 0),
                  child: Container(
                    child: Column(
                      children: [
                        Align(
                        alignment: Alignment.centerLeft,
                          child: Container(
                            child: Text('Oliver Queen'),
                          ),
                        ),
                        SizedBox(height:5),
                        Align(
                          alignment: Alignment.centerLeft,
                          child: Container(
                            child: Text('olieequeen77@gmail'),
                          ),
                        ),
                        SizedBox(height:5),
                        Align(
                          alignment: Alignment.centerLeft,
                          child: Container(
                            child: Text('9874561239'),
                          ),
                        ),
                      ],
                    ),
                  ),
                ), 
              ),

             Expanded(
               child: GridView(
                  gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2),
                  scrollDirection: Axis.vertical,
                  shrinkWrap: true,
                  children: <Widget>[
                    Container(
                      color: Colors.grey[100],
                      height: 90.0,
                      width: 110.0,
                       child: TextButton(onPressed: (){

                       },
                        child: Column(children: [
                        Icon(Icons.home,size: 45,
                         color: Colors.purple,),
                         Text("My Settings",
                         style: TextStyle(fontSize: 12,color: Colors.black)),
                       ],),
                       ),    
                     ),
                      Container(
                      color: Colors.grey[100],
                      height: 90.0,
                       width: 110.0,
                       child: TextButton(onPressed: (){

                       },
                        child: Column(children: [
                        Icon(Icons.home,size: 45,
                         color: Colors.purple,),
                         Text("My Settings",
                         style: TextStyle(fontSize: 12,color: Colors.black)),
                       ],),
                       ),
                     ),
                      Container(
                      color: Colors.grey[100],
                      height: 90.0,
                       width: 110.0,
                       child: TextButton(onPressed: (){

                       },
                        child: Column(children: [
                        Icon(Icons.home,size: 45,
                         color: Colors.purple,),
                         Text("My Settings",
                         style: TextStyle(fontSize: 12,color: Colors.black)),
                       ],),
                       ),
                     ),
                      Container(
                      color: Colors.grey[100],
                      height: 90.0,
                       width: 110.0,
                       child: TextButton(onPressed: (){

                       },
                        child: Column(children: [
                        Icon(Icons.home,size: 45,
                         color: Colors.purple,),
                         Text("My Settings",
                         style: TextStyle(fontSize: 12,color: Colors.black)),
                       ],),
                       ),
                     ),
                      Container(
                      color: Colors.grey[100],
                      height: 90.0,
                       width: 110.0,
                       child: TextButton(onPressed: (){

                       },
                        child: Column(children: [
                        Icon(Icons.home,size: 45,
                         color: Colors.purple,),
                         Text("My Settings",
                         style: TextStyle(fontSize: 12,color: Colors.black)),
                       ],),
                       ),
                     ),
                  ],
               ),
             )
            ],
          ),
        ), 
      );
     }
  }

这是它的样子

尝试将Container高度更改为200

return Scaffold(
  body: Container(
    height: 200,
    width: MediaQuery.of(context).size.width,
    color: Colors.grey[100],
    child: Column(
      children: [
        Expanded(
          child: Padding(
            padding: EdgeInsets.fromLTRB(10, 40, 0, 0),
            child: Container(
              child: Column(
                children: [
                  Align(
                    alignment: Alignment.centerLeft,
                    child: Container(
                      child: Text('Oliver Queen'),
                    ),
                  ),
                  SizedBox(height: 5),
                  Align(
                    alignment: Alignment.centerLeft,
                    child: Container(
                      child: Text('olieequeen77@gmail'),
                    ),
                  ),
                  SizedBox(height: 5),
                  Align(
                    alignment: Alignment.centerLeft,
                    child: Container(
                      child: Text('9874561239'),
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
        Expanded(
          child: GridView(
            gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                crossAxisCount: 2),
            scrollDirection: Axis.vertical,
            shrinkWrap: true,
            children: <Widget>[
              Container(
                color: Colors.grey[100],
                height: 90.0,
                width: 110.0,
                child: TextButton(
                  onPressed: () {},
                  child: Column(
                    children: [
                      Icon(
                        Icons.home,
                        size: 45,
                        color: Colors.purple,
                      ),
                      Text("My Settings",
                          style:
                              TextStyle(fontSize: 12, color: Colors.black)),
                    ],
                  ),
                ),
              ),
              Container(
                color: Colors.grey[100],
                height: 90.0,
                width: 110.0,
                child: TextButton(
                  onPressed: () {},
                  child: Column(
                    children: [
                      Icon(
                        Icons.home,
                        size: 45,
                        color: Colors.purple,
                      ),
                      Text("My Settings",
                          style:
                              TextStyle(fontSize: 12, color: Colors.black)),
                    ],
                  ),
                ),
              ),
              Container(
                color: Colors.grey[100],
                height: 90.0,
                width: 110.0,
                child: TextButton(
                  onPressed: () {},
                  child: Column(
                    children: [
                      Icon(
                        Icons.home,
                        size: 45,
                        color: Colors.purple,
                      ),
                      Text("My Settings",
                          style:
                              TextStyle(fontSize: 12, color: Colors.black)),
                    ],
                  ),
                ),
              ),
              Container(
                color: Colors.grey[100],
                height: 90.0,
                width: 110.0,
                child: TextButton(
                  onPressed: () {},
                  child: Column(
                    children: [
                      Icon(
                        Icons.home,
                        size: 45,
                        color: Colors.purple,
                      ),
                      Text("My Settings",
                          style:
                              TextStyle(fontSize: 12, color: Colors.black)),
                    ],
                  ),
                ),
              ),
              Container(
                color: Colors.grey[100],
                height: 90.0,
                width: 110.0,
                child: TextButton(
                  onPressed: () {},
                  child: Column(
                    children: [
                      Icon(
                        Icons.home,
                        size: 45,
                        color: Colors.purple,
                      ),
                      Text("My Settings",
                          style:
                              TextStyle(fontSize: 12, color: Colors.black)),
                    ],
                  ),
                ),
              ),
            ],
          ),
        )
      ],
    ),
  ),
);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM