Skip to content

Instantly share code, notes, and snippets.

@iampato
Created December 2, 2022 08:35
Show Gist options
  • Select an option

  • Save iampato/ad96855d3faffc12eda72eed14a3892b to your computer and use it in GitHub Desktop.

Select an option

Save iampato/ad96855d3faffc12eda72eed14a3892b to your computer and use it in GitHub Desktop.
A flutter extension on Row to add spaces between each child
/// extension on Row
/// to add a space between each child
extension RowExtension on Row {
Row addSpaceBetweenChildren(double space) {
final children = <Widget>[];
for (var i = 0; i < this.children.length; i++) {
children.add(this.children[i]);
if (i != this.children.length - 1) {
children.add(SizedBox(width: space));
}
}
return Row(
mainAxisAlignment: mainAxisAlignment,
mainAxisSize: mainAxisSize,
crossAxisAlignment: crossAxisAlignment,
textDirection: textDirection,
verticalDirection: verticalDirection,
textBaseline: textBaseline,
key: key,
children: children,
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment