Skip to content

Commit 161e59b

Browse files
committed
ResponsiveFlexible Creation
*Create ResponsiveFlexible for use in ResponsiveRowColumn.
1 parent 9c31c91 commit 161e59b

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

lib/responsive_row_column.dart

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class ResponsiveRowColumn extends StatelessWidget {
7171
verticalDirection: rowVerticalDirection,
7272
textBaseline: rowTextBaseline,
7373
children: [
74-
...buildRowChildren(children),
74+
...buildChildren(children, rowSpacing),
7575
],
7676
),
7777
)
@@ -85,35 +85,37 @@ class ResponsiveRowColumn extends StatelessWidget {
8585
verticalDirection: columnVerticalDirection,
8686
textBaseline: columnTextBaseline,
8787
children: [
88-
...buildColumnChildren(children),
88+
...buildChildren(children, columnSpacing),
8989
],
9090
),
9191
);
9292
}
9393

94-
List<Widget> buildRowChildren(List<Widget> children) {
94+
List<Widget> buildChildren(List<Widget> children, double spacing) {
9595
List<Widget> childrenList = [];
9696
for (int i = 0; i < children.length; i++) {
97-
childrenList.add(
98-
Flexible(
99-
flex: 1,
100-
fit: fillRow ? FlexFit.tight : FlexFit.loose,
101-
child: children[i]),
102-
);
103-
if (rowSpacing != null && i != children.length - 1)
104-
childrenList.add(Padding(padding: EdgeInsets.only(right: rowSpacing)));
97+
childrenList.add(children[i]);
98+
if (spacing != null && i != children.length - 1)
99+
childrenList.add(Padding(padding: EdgeInsets.only(bottom: spacing)));
105100
}
106101
return childrenList;
107102
}
103+
}
108104

109-
List<Widget> buildColumnChildren(List<Widget> children) {
110-
List<Widget> childrenList = [];
111-
for (int i = 0; i < children.length; i++) {
112-
childrenList.add(children[i]);
113-
if (columnSpacing != null && i != children.length - 1)
114-
childrenList
115-
.add(Padding(padding: EdgeInsets.only(bottom: columnSpacing)));
116-
}
117-
return childrenList;
105+
class ResponsiveFlexible extends StatelessWidget {
106+
final bool isFlexible;
107+
final int flex;
108+
final FlexFit flexFit;
109+
final Widget child;
110+
111+
const ResponsiveFlexible(
112+
{Key key, this.isFlexible = false, this.flex, this.flexFit, this.child})
113+
: super(key: key);
114+
115+
@override
116+
Widget build(BuildContext context) {
117+
return isFlexible
118+
? Flexible(flex: flex, fit: flexFit, child: child)
119+
: child;
118120
}
119121
}

0 commit comments

Comments
 (0)