Make buttons in a row have the same width in flutter

esthrim picture esthrim · Oct 1, 2018 · Viewed 20.7k times · Source

If I want to make two or more Buttons in a Row to have the same Width, how do I make it? For examples I have three RaisedButtons with different title let say Approve, Reject and Need Revise and if I put the three Buttons in a Row, they will have different Width and I don't want it. What I need is for they have the same Width.

Answer

diegoveloper picture diegoveloper · Oct 1, 2018

You can use a Row wrapping your children with Expanded:

Row(
  children: <Widget>[
    Expanded(
      child: RaisedButton(
        child: Text('Approve'),
        onPressed: () => null,
      ),
    ),
    Expanded(
      child: RaisedButton(
        child: Text('Reject'),
        onPressed: () => null,
      ),
    ),
    Expanded(
      child: RaisedButton(
        child: Text('Need Revise'),
        onPressed: () => null,
      ),
    )
  ],
);