How do I keep a RaisedButton
from expanding to fill an Expanded
that contains it? I want to create three columns of widths proportional to the space available, but I want the child in each column to be its natural size, without consuming the entire width of its parent Expanded
.
Widget _controls(BuildContext cx) {
return Row(
children: [
Expanded(
flex: 1,
child: player.isOnFirstItem
? Container()
: IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () => control.gotoPreviousItem(),
),
),
Expanded(
flex: 4,
child: player.isComplete()
? Text(player.currentItem.status) // I'll be adding more here
: RaisedButton(
child: Text(player.currentItem.actionText),
onPressed: () => player.currentItem.action(),
),
),
Expanded(
flex: 1,
child: player.isOnLastItem
? Container()
: IconButton(
icon: Icon(Icons.arrow_forward),
onPressed: () => player.gotoNextItem(),
),
),
],
);
The RaisedButton
also fills the flex space when I further nest it within a Container
. I can't figure out which properties might prevent this.
Searching around for answers, it seems that everyone is trying to accomplish just the opposite.