spacerEvery method
Inserts a Spacer
widget between each widget in the list.
This helps to evenly distribute widgets inside a Row
or Column
with spacing between them.
Example:
Row(children: [Text("1"), Text("2"), Text("3")].spacerEvery())
Implementation
List<Widget> spacerEvery() {
List<Widget> list = <Widget>[];
forEachIndexed((index, element) {
index == (length - 1)
? list.add(this[index])
: list.addAll([this[index], const Spacer()]);
});
return list;
}