I want to use a Row inside a horizontally scrolling list. When there are only few children in the row, the row should take up the full with and apply mainAxisAlignment: MainAxisAlignment.spaceEvenly such that it looks like this:
However when there are a lot of items, such that it doesn't fully fit on the screen, the row should be scrollable.
I currently have this code:
Container(
height: 40,
child: ListView(
scrollDirection: Axis.horizontal,
children: <Widget>[
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Container(
width: 100,
height: 40,
color: Colors.red
),
Container(
width: 100,
height: 40,
color: Colors.blue
),
],
),
],
),
),
However the Row's width is only as wide as the children's combined with, such that it doesn't apply mainAxisAlignment: MainAxisAlignment.spaceEvenly. So it looks like this:
Is there a good way to achieve this in Flutter? So I need to expand the Row to atlest the full ListView with but also allow it to go larger.



