withGapInBetween method
withGapInBetween Returns a new list with gaps of the specified size between each widget.
If the list is empty, an empty list is returned.
Example:
List<Widget> widgets = [Widget1(), Widget2(), Widget3()];
List<Widget> separatedWidgets = widgets.withGapInBetween(10.0);
Implementation
List<Widget> withGapInBetween(double gapSize) {
List<Widget> separatedList = <Widget>[];
for (var i = 0; i < length; i++) {
separatedList.add(this[i]);
ifNotLast(i) ? separatedList.add(Gap(gapSize)) : null;
}
return separatedList;
}