Flutter: How to make a button expand to the size of its parent?
Wrapping with a ButtonTheme
with minWidth: double.infinity
allows to provide constraints
ButtonTheme(
minWidth: double.infinity,
child: MaterialButton(
onPressed: () {},
child: Text('Raised Button'),
),
),
or after https://github.com/flutter/flutter/pull/19416 landed
MaterialButton(
onPressed: () {},
child: SizedBox.expand(
width: double.infinity,
child: Text('Raised Button'),
),
),
Add the crossAxisAlignment
property to your Row
;
crossAxisAlignment: CrossAxisAlignment.stretch
We can add Button insider Container.
Solution:
Container(
width: double.infinity,
child: RaisedButton(
onPressed: null,
child: Text('NEXT'),
),
)