How can I create a row w/2 buttons that, together, take up the space of their parent (the row)? I want to place this row immediately above the bottom navigation bar at times and then at other times I want it to take the place of the bottom navigation bar. Can I do it just using Row
? I've tried persistentFooterButtons
with a child of Row
and children of FractionallySizedBox
but it results in an overflow error and the buttons don't take up the height of of the persistentFooterButtons
. There's got to be a better, more straight-forward, approach. Just learning Flutter.
This is a rough example of what I want placed at the bottom of the screen (buttons should be of equal height), where the bottom nav bar would be... and/or immediately above.
CodePudding user response:
Wrap both your buttons with Expanded
so that they take same amount of width and fill the row.
CodePudding user response:
You can either add persistentFooterButtons
to the Scaffold
like
Scaffold(
persistentFooterButtons: [
TextButton(),
TextButton()
]
)
Or in the view:
Column(
children: [
Expanded(child: yourContent), // To use max height space
Row(
children: [
Expanded(child: TextButton()),
Expanded(child: TextButton()),,
]
),
]
),
To give a different width you can add flex
to the Expanded
or use Flexible
and add flex