Flutter:列对齐项目以具有相同的宽度
Flutter: Column align items to have the same width
我正在尝试将列内的小部件与 CrossAxisAlignment.center 对齐,但我也希望这些小部件具有相同的宽度。我怎样才能做到这一点?
你可以通过将 CrossAxisAlignment
设置为拉伸然后将 Column
包裹在 IntrinsicWidth
中来获得类似的东西,如果你想给它们一个特定的宽度使用stepWidth
属性
Center(
child: IntrinsicWidth(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
RaisedButton(
child: Text("hello"),
onPressed: () {},
),
RaisedButton(
child: Text("another hello"),
onPressed: () {},
),
RaisedButton(
child: Text("DB"),
onPressed: () {},
),
],
),
),
),
我正在尝试将列内的小部件与 CrossAxisAlignment.center 对齐,但我也希望这些小部件具有相同的宽度。我怎样才能做到这一点?
你可以通过将 CrossAxisAlignment
设置为拉伸然后将 Column
包裹在 IntrinsicWidth
中来获得类似的东西,如果你想给它们一个特定的宽度使用stepWidth
属性
Center(
child: IntrinsicWidth(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
RaisedButton(
child: Text("hello"),
onPressed: () {},
),
RaisedButton(
child: Text("another hello"),
onPressed: () {},
),
RaisedButton(
child: Text("DB"),
onPressed: () {},
),
],
),
),
),