Flutter 底部的RenderFlex溢出了23个像素
如何解决“底部的RenderFlex溢出了23个像素”的异常。在我的应用程序中,我创建了Gridview。但是每次我运行代码时都会得到RenderFlex。我用expnded add包装GridviewFlutter 底部的RenderFlex溢出了23个像素,flutter,flutter-layout,flutter-gridview,Flutter,Flutter Layout,Flutter Gridview,如何解决“底部的RenderFlex溢出了23个像素”的异常。在我的应用程序中,我创建了Gridview。但是每次我运行代码时都会得到RenderFlex。我用expnded add包装Gridview 滚动方向:轴垂直 收缩膜:对 但没有效果仍然得到这个例外。谁能纠正我;我在代码中做错了什么?我该怎么办呢 这是我的代码,我在其中遇到错误: Widget build(BuildContext context) { return Scaffold( body:Containe
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)),
],),
),
),
],
),
)
],
),
),
);
}
}
小部件构建(构建上下文){
返回脚手架(
主体:容器(
身高:150,
宽度:MediaQuery.of(context).size.width,
颜色:颜色。灰色[100],
子项:列(子项:[
扩大(
孩子:填充(
填充:从LTRB(10,40,0,0)开始的边缘设置,
子:容器(
子:列(
儿童:[
对齐(
对齐:alignment.centerLeft,
子:容器(
孩子:文本(“奥利弗女王”),
),
),
尺寸箱(高度:5),
对齐(
对齐:alignment.centerLeft,
子:容器(
子:文本('olieequeen77@gmail'),
),
),
尺寸箱(高度:5),
对齐(
对齐:alignment.centerLeft,
子:容器(
子项:文本('9874561239'),
),
),
],
),
),
),
),
扩大(
子:GridView(
gridDelegate:SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount:2),
滚动方向:轴垂直,
收缩膜:对,
儿童:[
容器(
颜色:颜色。灰色[100],
身高:90.0,
宽度:110.0,
子项:文本按钮(按下时:(){
},
子项:列(子项:[
图标(图标。主页,尺寸:45,
颜色:颜色。紫色,),
文本(“我的设置”,
样式:TextStyle(字体大小:12,颜色:Colors.black)),
],),
),
),
容器(
颜色:颜色。灰色[100],
身高:90.0,
宽度:110.0,
子项:文本按钮(按下时:(){
},
子项:列(子项:[
图标(图标。主页,尺寸:45,
颜色:颜色。紫色,),
文本(“我的设置”,
样式:TextStyle(字体大小:12,颜色:Colors.black)),
],),
),
),
容器(
颜色:颜色。灰色[100],
身高:90.0,
宽度:110.0,
子项:文本按钮(按下时:(){
},
子项:列(子项:[
图标(图标。主页,尺寸:45,
颜色:颜色。紫色,),
文本(“我的设置”,
样式:TextStyle(字体大小:12,颜色:Colors.black)),
],),
),
),
容器(
颜色:颜色。灰色[100],
身高:90.0,
宽度:110.0,
子项:文本按钮(按下时:(){
},
子项:列(子项:[
图标(图标。主页,尺寸:45,
颜色:颜色。紫色,),
文本(“我的设置”,
样式:TextStyle(字体大小:12,颜色:Colors.black)),
],),
),
),
容器(
颜色:颜色。灰色[100],
身高:90.0,
宽度:110.0,
子项:文本按钮(按下时:(){
},
子项:列(子项:[
图标(图标。主页,尺寸:45,
颜色:颜色。紫色,),
文本(“我的设置”,
样式:TextStyle(字体大小:12,颜色:Colors.black)),
],),
),
),
],
),
)
],
),
),
);
}
}
尝试将
容器的高度更改为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)),
],
),
),
),
],
),
)
],
),
),
);
}
返回脚手架(
主体:容器(
身高:200,
宽度:MediaQuery.of(context).size.width,
颜色:颜色。灰色[100],
子:列(
儿童:[
扩大(
孩子:填充(
填充:从LTRB(10,40,0,0)开始的边缘设置,
子:容器(
子:列(
儿童:[
对齐(
对齐:alignment.centerLeft,
子:容器(
孩子:文本(“奥利弗女王”),
),
),
尺寸箱(高度:5),
对齐(
校准:Alig