Please refer to my code and Screen Shot below
Top two rows are build based on MainAxisAlignment.spaceBetween
widget and a bottom row is on MainAxisAlignment.spaceBetween
, respectively.
As you can see in Screen Shot,MainAxisAlignment.spaceBetween
have no spaces like spacebetween, and I understood this is default behaviour of MainAxisAlignment
.
However, I want keep same spaces between the items in 5 items, even if it consists of less than 5 items(like two items shown in Screen shot).
Is there any good ideas to implement this ?
thanks for your helpful advise.
final List<String> _icon = [
"lock.png",
"cheer.png",
"map.png",
"stake.png",
"sushi.png",
"lock.png",
"cheer.png",
"map.png",
"stake.png",
"sushi.png",
"cheer.png",
"map.png"
];
var iconChunks = _icon.slices(5).toList();
Column(
children: iconChunks.map((e) => Padding(
padding: const EdgeInsets.only(bottom: 10.0),
child: Row(
mainAxisAlignment: e.length ==5 ? MainAxisAlignment.spaceBetween :MainAxisAlignment.start,
children: e.map((s) => selectIcon(id: 1, iconPass: s)
).toList(),
),
))
.toList()
),
2
Answers
Have you tried using GridViewBuilder? Maybe this will help.
You can easily maintain same height and weight by
Gridview
.Column
Spacebetween
andstart
are totally different concept.As you are don’t know about list, it may be increase or decrease better you should have to useGridview
.