I have a Row filling a Container which may have between one and three fixed-sized children. I'm using MainAxisAlignment.spaceBetween, and when there's more than one child, it works as expected: with two children, they end up at the edges, and if there are three, two end up at the edges and one in the center.
Container(
width: 200,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(width: 30, height: 20),
SizedBox(width: 30, height: 20),
SizedBox(width: 30, height: 20),
],
),
);
However, when there's only one child, it's placed at the start of the Row, and I'd like to have it at the center. I can certainly achieve what I need by checking the number of children beforehand and changing the MainAxisAlignment to center, but I was wondering if there's a more elegant way to combine spaceBetween and center.


