gap method
Adds spacing between children in a Row widget.
spacing
: The width of the space to add between children.
Returns a Row widget with spacing added between its children.
Implementation
Row gap(double spacing) {
List<Widget> newChildren = [];
for (int i = 0; i < children.length; i++) {
newChildren.add(children[i]);
if (i != children.length - 1) {
newChildren.add(SizedBox(width: spacing));
}
}
return Row(
mainAxisAlignment: mainAxisAlignment,
mainAxisSize: mainAxisSize,
crossAxisAlignment: crossAxisAlignment,
textDirection: textDirection,
verticalDirection: verticalDirection,
textBaseline: textBaseline,
children: newChildren,
);
}