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: this.key,
    mainAxisAlignment: this.mainAxisAlignment,
    mainAxisSize: this.mainAxisSize,
    crossAxisAlignment: this.crossAxisAlignment,
    textDirection: this.textDirection,
    verticalDirection: this.verticalDirection,
    textBaseline: this.textBaseline,
    children: newChildren,
  );
}