我想將我的盒子分成兩部分,由分隔線分隔我嘗試了這樣的事情:
Card(
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
Container(
color: Colors.green,
width: 25.w-8-4,
child: const Text("box1")),
const VerticalDivider(
color: Colors.red,
width: 16,
thickness: 2,
),
Container(
color: Colors.indigo,
width: 75.w-8-4,
child: const Text("box2"),
)
],
)
)
使用
但不幸的是,我似乎看不到垂直分隔線(空間只是白色的?)。并且如果有一種方式對左右容器說“請消耗大約 25% 和 75% 的空間”,在繪制分隔線后剩下的內容,那將是很棒的。有沒有辦法這樣說?這也使得在容器上使用填充/邊距變得更容易。不必分別從容器的寬度中減去東西。
非常感謝
uj5u.com熱心網友回復:
你考慮過使用Expanded嗎?
return Row(
children:[
Expanded(
flex:25,
child: Container(
color: Colors.green,
child: Text('box1'),
),
),
Expanded(
flex:75,
child: Container(
color: Colors.blue,
child: Text('box2'),
),
),
],
);
相應地添加邊距/填充。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/459947.html
上一篇:Flutter動態底部導航欄
