Created
December 2, 2022 08:35
-
-
Save iampato/ad96855d3faffc12eda72eed14a3892b to your computer and use it in GitHub Desktop.
A flutter extension on Row to add spaces between each child
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// 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