11import 'package:flutter/cupertino.dart' ;
22import 'package:flutter/widgets.dart' ;
33
4+ /// A convenience wrapper for responsive [Row] and
5+ /// [Column] switching with padding and spacing.
6+ ///
7+ /// ResponsiveRowColumn combines responsiveness
8+ /// behaviors for managing rows and columns into one
9+ /// convenience widget. This widget requires all [children]
10+ /// to be [ResponsiveRowColumnItem] widgets.
11+ /// Row vs column layout is controlled by [rowColumn] .
12+ /// RowColumn is Row layout when true and Column
13+ /// layout when false.
14+ /// Add spacing between widgets with [rowSpacing] and
15+ /// [columnSpacing] . Add padding around widgets with
16+ /// [rowPadding] and [columnPadding] .
17+ ///
18+ /// See [ResponsiveRowColumnItem] for [Flex] and
19+ /// [FlexFit] options.
420class ResponsiveRowColumn extends StatelessWidget {
521 final List <ResponsiveRowColumnItem > children;
622 final bool rowColumn;
@@ -20,7 +36,6 @@ class ResponsiveRowColumn extends StatelessWidget {
2036 final double columnSpacing;
2137 final EdgeInsets rowPadding;
2238 final EdgeInsets columnPadding;
23- final bool fillRow;
2439 get isRow => rowColumn;
2540 get isColumn => ! rowColumn;
2641
@@ -42,7 +57,6 @@ class ResponsiveRowColumn extends StatelessWidget {
4257 this .columnTextBaseline,
4358 this .rowSpacing,
4459 this .columnSpacing,
45- this .fillRow = false ,
4660 this .rowPadding = EdgeInsets .zero,
4761 this .columnPadding = EdgeInsets .zero})
4862 : super (key: key);
@@ -80,6 +94,7 @@ class ResponsiveRowColumn extends StatelessWidget {
8094 );
8195 }
8296
97+ /// Logic to construct widget [children] .
8398 List <Widget > buildChildren (
8499 List <ResponsiveRowColumnItem > children, bool rowColumn, double spacing) {
85100 // Sort ResponsiveRowColumnItems by their order.
@@ -91,7 +106,7 @@ class ResponsiveRowColumn extends StatelessWidget {
91106 return a.columnOrder.compareTo (b.columnOrder);
92107 }
93108 });
94- // Add padding between items .
109+ // Add padding between widgets. .
95110 List <Widget > widgetList = [];
96111 for (int i = 0 ; i < childrenHolder.length; i++ ) {
97112 widgetList.add (childrenHolder[i].copyWith (rowColumn: rowColumn));
@@ -105,6 +120,16 @@ class ResponsiveRowColumn extends StatelessWidget {
105120 }
106121}
107122
123+ /// A wrapper for [ResponsiveRowColumn] children with
124+ /// responsiveness.
125+ ///
126+ /// Control the order of widgets within [ResponsiveRowColumn]
127+ /// by assigning a [rowOrder] or [columnOrder] value.
128+ /// Widgets without an order value are ranked behind
129+ /// those with order values.
130+ /// Set a widget's [Flex] value through [rowFlex] and
131+ /// [columnFlex] . Set a widget's [FlexFit] through
132+ /// [rowFit] and [columnFit] .
108133class ResponsiveRowColumnItem extends StatelessWidget {
109134 final Widget child;
110135 final int rowOrder;
@@ -129,9 +154,9 @@ class ResponsiveRowColumnItem extends StatelessWidget {
129154
130155 @override
131156 Widget build (BuildContext context) {
132- if (rowColumn && rowFlex != null ) {
157+ if (rowColumn && ( rowFlex != null || rowFit != null ) ) {
133158 return Flexible (flex: rowFlex, fit: rowFit, child: child);
134- } else if (! rowColumn && columnFlex != null ) {
159+ } else if (! rowColumn && ( columnFlex != null || columnFit != null ) ) {
135160 return Flexible (flex: columnFlex, fit: columnFit, child: child);
136161 }
137162
0 commit comments