flutter flutter Listview -> 容器“宽度”不工作?
/示例/ ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
scaffold
body : ListView
children : [
Container (
width: 100, // Not Working
height: 100, // Ok
color: Colors.red.
),
]
!!!但是 !!!
scaffold
body : ListView
children : [
Stack(
children : [
Container (
width: 100, // OK
height: 100, // Ok
color: Colors.red.
),
]
为什么??
最佳答案
试试下面的代码,把你的 Container 包裹在 UnconstrainedBox()
ListView(
shrinkWrap: true,
children: [
UnconstrainedBox(
child: Container(
width: 100, // OK
height: 100, // OK
color: Colors.red,
),
)
],
),
关于 flutter Listview -> 容器 'width' 不工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71509510/