我在一个列中有几个RaisedButton小部件,它们根据文本的不同具有不同的宽度。我希望它们是相同的宽度,但我不想设置静态宽度,因为它应该能够响应语言和屏幕大小/形状的变化。应调整较小的小部件的大小,以与列中最大的小部件的宽度相匹配。做这件事最好的方法是什么?
谢谢!
Column(
children: <Widget>[
RaisedButton(
child: Text("Btn1"),
onPressed: (){},
),
RaisedButton(
child: Text("LongerBtn2"),
color: Colors.Red,
onPressed: (){},
)
],
),发布于 2019-11-29 00:06:19
可以这样做:
IntrinsicWidth( // <- Sizes its child's width to the child's maximum intrinsic width
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, // <- all children will try to take as much space as possible
children: <Widget>[
RaisedButton(
child: Text("Btfffffff fsdfds dsfsa n1"),
color: Colors.green,
onPressed: () {},
),
RaisedButton(
child: Text("LongerBtn2"),
color: Colors.red,
onPressed: () {},
)
],
),
)https://stackoverflow.com/questions/59092541
复制相似问题