Skip to content

Commit d32cfbd

Browse files
committed
Responsive Row Column Creation #3 Part 2
*Set null order to max int value.
1 parent 6bcb983 commit d32cfbd

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

lib/responsive_row_column.dart

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ class ResponsiveRowColumn extends StatelessWidget {
9191
);
9292
}
9393

94-
List<ResponsiveRowColumnItem> buildChildren(
94+
List<Widget> buildChildren(
9595
List<ResponsiveRowColumnItem> children, bool rowColumn, double spacing) {
96+
// Sort ResponsiveRowColumnItems by their order.
9697
List<ResponsiveRowColumnItem> childrenHolder = children;
9798
childrenHolder.sort((a, b) {
9899
if (rowColumn) {
@@ -101,10 +102,11 @@ class ResponsiveRowColumn extends StatelessWidget {
101102
return a.columnOrder.compareTo(b.columnOrder);
102103
}
103104
});
104-
List<Widget> widgetList = childrenHolder;
105-
for (int i = 0; i < children.length; i++) {
106-
widgetList.add(children[i]);
107-
if (spacing != null && i != children.length - 1)
105+
// Add padding between items.
106+
List<Widget> widgetList = [];
107+
for (int i = 0; i < childrenHolder.length; i++) {
108+
widgetList.add(childrenHolder[i]);
109+
if (spacing != null && i != childrenHolder.length - 1)
108110
widgetList.add(Padding(padding: EdgeInsets.only(bottom: spacing)));
109111
}
110112
return widgetList;
@@ -122,8 +124,8 @@ class ResponsiveRowColumnItem extends StatelessWidget {
122124
const ResponsiveRowColumnItem(
123125
{Key key,
124126
@required this.child,
125-
this.rowOrder,
126-
this.columnOrder,
127+
this.rowOrder = 1073741823,
128+
this.columnOrder = 1073741823,
127129
this.isFlexible = false,
128130
this.flex,
129131
this.flexFit})

lib/responsive_value.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ class ResponsiveVisibility extends StatelessWidget {
142142
conditions.sort((a, b) => a.breakpoint.compareTo(b.breakpoint));
143143
// Get visible value from active condition.
144144
visibleValue = ResponsiveValue(context,
145-
defaultValue: visibleValue,
146-
valueWhen: [Condition.smallerThan(name: DESKTOP, value: false)]).value;
145+
defaultValue: visibleValue, valueWhen: conditions)
146+
.value;
147147

148148
return Visibility(
149149
child: child,
@@ -175,19 +175,19 @@ class Condition<T> {
175175
assert(breakpoint == null || name == null),
176176
assert((condition == Conditional.EQUALS) ? name != null : true);
177177

178-
Condition.equals({@required String name, @required T value})
178+
Condition.equals({@required String name, T value})
179179
: this.breakpoint = null,
180180
this.name = name,
181181
this.condition = Conditional.EQUALS,
182182
this.value = value;
183183

184-
Condition.largerThan({int breakpoint, String name, @required T value})
184+
Condition.largerThan({int breakpoint, String name, T value})
185185
: this.breakpoint = breakpoint,
186186
this.name = name,
187187
this.condition = Conditional.LARGER_THAN,
188188
this.value = value;
189189

190-
Condition.smallerThan({int breakpoint, String name, @required T value})
190+
Condition.smallerThan({int breakpoint, String name, T value})
191191
: this.breakpoint = breakpoint,
192192
this.name = name,
193193
this.condition = Conditional.SMALLER_THAN,

0 commit comments

Comments
 (0)