flutterdartbuttonflutter-layoutflutter-widget

Make buttons in a row have the same width in flutter


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.


Solution

  • 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,
          ),
        )
      ],
    );