【发布时间】:2021-12-17 01:16:02
【问题描述】:
有没有办法为GridView 中的孩子设置固定大小?我想让红色的高度相同。我尝试使用Expanded 或指定Container 的大小,但它不起作用。 GridView 只是让孩子大小相同。
注意:我尝试指定红色容器的高度。没用。
这就是我得到的。
这就是我所做的。
return GridView.count(
crossAxisCount: 2,
children: List.generate(drinksData.length, (index) {
return Container(
padding: EdgeInsets.all(20.0),
child: Column(
children: [
Expanded(
child: Container(
color: Colors.red,
),
),
Text(drinksData[index].label),
],
),
);
}),
);
【问题讨论】:
-
是的!只需在容器中添加
height: 100 -
嘿戴维斯,感谢您的回复,但我尝试指定高度。它不起作用。 GridView 只是让它对孩子来说是平等的。你可以用代码试试看。
-
检查更新的代码!
标签: flutter dart user-interface gridview