【发布时间】:2018-09-16 09:06:13
【问题描述】:
我正在尝试创建方形按钮,但 Expanded 似乎与容器的工作方式不同。以如下代码为例
new Expanded(
flex: 2,
child: new Column(
children: <Widget>[
new Expanded(
child:new Row(
children: <Widget>[
new Expanded(child: new MaterialButton(...)),
new Expanded(child: new MaterialButton(....)),
new Expanded(child: new Container(color: Colors.red)),
new Expanded(child: new Container(color: Colors.green)),
]
)
)
],
)
)
....
它显示两个水平展开但不垂直展开的按钮。同时,容器将水平和垂直扩展。如果我执行以下操作,也会出现同样的效果:
new Expanded(
flex: 2,
child: new Column(
children: <Widget>[
new Expanded(
child:new Column(
children: <Widget>[
new Expanded(child: new MaterialButton(...)),
new Expanded(child: new MaterialButton(....)),
new Expanded(child: new Container(color: Colors.red)),
new Expanded(child: new Container(color: Colors.green)),
]
)
)
],
)
)
....
我将行更改为列的位置。按钮将垂直扩展,但不会水平扩展,而容器将同时进行。
有没有办法让我的按钮在垂直和水平方向上展开以适应其父级?
【问题讨论】: