FullFlex constructor

FullFlex({
  1. required bool isRow,
  2. required String dims,
  3. required List<Widget> children,
  4. MainAxisAlignment mainAccessAlignment = MainAxisAlignment.center,
  5. 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,
        );
}