FullFlex constructor
FullFlex({
- required bool isRow,
- required String dims,
- required List<
Widget> children, - MainAxisAlignment mainAccessAlignment = MainAxisAlignment.center,
- CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.center,
Implementation
FullFlex({
required this.isRow,
required this.dims,
required this.children,
MainAxisAlignment mainAccessAlignment = MainAxisAlignment.center,
CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.center,
}) {
List<String> splitDims = this.dims.split(" ");
for (int i = 0; i < children.length; i++) {
if (splitDims.length <= i ||
splitDims[i] == "auto" ||
splitDims[i].isEmpty) {
this.wrappedChildren.add(this.children[i]);
} else if (splitDims[i].endsWith("*")) {
int? flx;
if ((flx = int.tryParse(
splitDims[i].substring(0, splitDims[i].length - 1))) !=
null) {
this
.wrappedChildren
.add(Expanded(flex: flx!, child: this.children[i]));
} else {
_throwExceptionForValue(splitDims[i]);
}
} else if (int.tryParse(splitDims[i]) != null) {
int w = int.tryParse(splitDims[i])!;
this.wrappedChildren.add(isRow
? SizedBox(width: w.toDouble(), child: this.children[i])
: SizedBox(height: w.toDouble(), child: this.children[i]));
} else {
_throwExceptionForValue(splitDims[i]);
}
}
this.flex = isRow
? new Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: crossAxisAlignment,
mainAxisAlignment: mainAccessAlignment,
children: wrappedChildren,
)
: new Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: crossAxisAlignment,
mainAxisAlignment: mainAccessAlignment,
children: wrappedChildren,
);
}