这是我的代码,我运行了代码,但没有输出显示
Divider(thickness: 5),
Padding(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 5),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Best Destination",
style: TextStyle(color: Colors.teal, fontSize: 20),
),
Text("SEE ALL")
],
),
),
GridView(
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2),
children: [
Container(
color: Colors.blue,
margin: EdgeInsets.all(5),
),
Container(
color: Colors.blue,
margin: EdgeInsets.all(5),
),
Container(
color: Colors.blue,
margin: EdgeInsets.all(5),
),
Container(
color: Colors.blue,
margin: EdgeInsets.all(5),
),
Container(
color: Colors.blue,
margin: EdgeInsets.all(5),
),
],
),发布于 2022-10-03 18:55:22
当顶层小部件为GridView时,尝试用Expanded包装Column
class GriVIssue extends StatelessWidget {
const GriVIssue({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
Divider(thickness: 5),
Padding(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 5),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Best Destination",
style: TextStyle(color: Colors.teal, fontSize: 20),
),
Text("SEE ALL")
],
),
),
Expanded(
child: GridView(
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2),
children: [
Container(
color: Colors.blue,
margin: EdgeInsets.all(5),
),
Container(
color: Colors.blue,
margin: EdgeInsets.all(5),
),
Container(
color: Colors.blue,
margin: EdgeInsets.all(5),
),
Container(
color: Colors.blue,
margin: EdgeInsets.all(5),
),
Container(
color: Colors.blue,
margin: EdgeInsets.all(5),
),
],
),
),
],
),
);
}
}查看有关此无界高度/宽度解码颤振的更多信息
https://stackoverflow.com/questions/73938109
复制相似问题