有沒有辦法讓孩子在里面有一個固定的大小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),
],
),
);
}),
);
uj5u.com熱心網友回復:
GridView.count(
crossAxisCount: 2,
children: List.generate(drinksData.length, (index) {
return Container(
padding: const EdgeInsets.all(20.0),
child: Column(
children: [
Expanded(
child: Container(
// height:90,//or whatever size you want!
color: Colors.red,
),
),
SizedBox(
height: 45,
child: Text(drinksData[index])
),
],
),
);
}),
)
```
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/345327.html
