TheRedhat
TheRedhat

Reputation: 483

Flutter: Column align items to have the same width

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?

Upvotes: 17

Views: 10188

Answers (1)

Raouf Rahiche
Raouf Rahiche

Reputation: 31326

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

enter image description here

Upvotes: 52

Related Questions