withGap method

Row withGap(
  1. double space
)

Adds a gap between each child.

Implementation

Row withGap(double space) {
  assert(space >= 0, 'Space should be a non-negative value.');

  List<Widget> newChildren = [];
  for (int i = 0; i < children.length; i++) {
    newChildren.add(children[i]);
    if (i < children.length - 1) {
      newChildren.add(SizedBox(width: space));
    }
  }

  return Row(
    key: key,
    mainAxisAlignment: mainAxisAlignment,
    mainAxisSize: mainAxisSize,
    crossAxisAlignment: crossAxisAlignment,
    textDirection: textDirection,
    verticalDirection: verticalDirection,
    textBaseline: textBaseline,
    children: newChildren,
  );
}