Flutter:列对齐项具有相同的宽度 [英] Flutter: Column align items to have the same width
本文介绍了Flutter:列对齐项具有相同的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图将列内的小部件与CrossAxisAlignment.center对齐在中心,但我也希望这些小部件具有相同的宽度.我该如何实现?
I'm trying to align the widgets inside the column to be in the center with CrossAxisAlignment.center but I also want that the Widgets have the same width. How can I achieve this?
推荐答案
您可以通过将CrossAxisAlignment
设置为拉伸,然后将Column
包裹在IntrinsicWidth
中来获得类似的效果,如果您想给使用stepWidth
属性
you can get something similar to that by setting the CrossAxisAlignment
to stretch and then wrap the Column
in a IntrinsicWidth
and if you want to give them a specific width use the stepWidth
property
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: () {},
),
],
),
),
),
这篇关于Flutter:列对齐项具有相同的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文