我在列中有几个RaisedButton小部件,根据它们的文本它们具有不同的宽度。我希望它们的宽度相同,但是我不想设置静态宽度,因为它应该能够响应语言和屏幕尺寸/形状的变化。较小的窗口小部件应调整大小以匹配列中最大窗口小部件的宽度。最好的方法是什么?
谢谢!
% 10
答案 0 :(得分:1)
可以这样做:
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: () {},
)
],
),
)