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?
Change width of a row Row normally takes available space and we can control that by wrapping inside a Container or SizedBox widget. You can wrap the Row inside the Container and add width to the container. Then the Row will take the same width as a Container.
Alignment Properties:In column, children are aligned from top to bottom. Main Axis is vertical and the Cross Axis is horizontal. MainAxisAlignment aligns its children vertically and CrossAxisAlignment aligns horizontally in that Column.
To set Margin for Container widget in Flutter, set margin property wit the required EdgeInsets value. We can set margin for top, right, bottom, and left with separate values using EdgeInsets. fromLTRB(), or a set a same value for margin on all sides.
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: () {},
),
],
),
),
),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With