Flutter: Column align items to have the same width

孤街浪徒 提交于 2020-05-26 04:11:08

问题


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?


回答1:


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: () {},
              ),
            ],
          ),
        ),
      ),



来源:https://stackoverflow.com/questions/51684730/flutter-column-align-items-to-have-the-same-width

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!