1

I am working on an app in Flutter, and I want to use ButtonBar. however, when trying to make the children utilize the space the buttons only utilize the minimal space

        Padding(
          padding: const EdgeInsets.all(8.0),
          child: ButtonBar(
            mainAxisSize: MainAxisSize.max,
            alignment: MainAxisAlignment.center,
            children: <Widget>[
              RaisedButton(
                child: Text('Save'),
                onPressed: () {
                  Navigator.push(context,
                      MaterialPageRoute(builder: (context) => OtpPage()));
                },
              ),
            ],
          ),
        ),

        Padding(
          padding: const EdgeInsets.all(8.0),
          child: ButtonBar(
            mainAxisSize: MainAxisSize.max,
            alignment: MainAxisAlignment.center,
            children: <Widget>[
              RaisedButton(
                child: Text('Save'),
                onPressed: () {
                  Navigator.push(context,
                      MaterialPageRoute(builder: (context) => OtpPage()));
                },
              ),
            ],
          ),
        ),

enter image description here

Any idea how to get the button to utilize more space

cipli onat
  • 1,943
  • 1
  • 11
  • 26
Mustafa ALMulla
  • 870
  • 2
  • 10
  • 23
  • I found a solution [here](https://stackoverflow.com/questions/50014342/button-width-match-parent-flutter/50017126#50017126) and it does work. – Mustafa ALMulla Jun 09 '19 at 15:28

1 Answers1

-1

You can edit the button size with ButtonTheme property

Raised buttons have a minimum size of 88.0 by 36.0 which can be overridden with ButtonTheme.

Secondly,

You can try to wrap the buttons with Expanded widget

        Padding(
          padding: const EdgeInsets.all(8.0),
          child: ButtonBar(
            mainAxisSize: MainAxisSize.max,
            alignment: MainAxisAlignment.center,
            children: <Widget>[
              Expanded(
                child: RaisedButton(
                  child: Text('Save'),
                  onPressed: () {
                    Navigator.push(context,
                        MaterialPageRoute(builder: (context) => OtpPage()));
                  },
                ),
              ),
            ],
          ),
        ),
cipli onat
  • 1,943
  • 1
  • 11
  • 26