FlexItem.builder constructor

const FlexItem.builder({
  1. Key? key,
  2. int? paintOrder,
  3. SizeUnit? width,
  4. SizeUnit? height,
  5. SizeUnit? minWidth,
  6. SizeUnit? maxWidth,
  7. SizeUnit? minHeight,
  8. SizeUnit? maxHeight,
  9. double flexGrow,
  10. double flexShrink,
  11. double? aspectRatio,
  12. PositionUnit? top,
  13. PositionUnit? left,
  14. PositionUnit? bottom,
  15. PositionUnit? right,
  16. BoxAlignmentGeometry? alignSelf,
  17. required Widget builder(
    1. BuildContext context,
    2. LayoutBox box
    ),
})

Creates a flex item with a builder function for dynamic child construction.

The builder parameter is required and provides a function that constructs the child widget dynamically. The builder receives the BuildContext and a LayoutBox containing layout information that can be used to adapt the content.

The flexGrow parameter controls how much this item grows relative to its siblings when there is extra space in the main axis. A value of 0.0 means the item will not grow. Default is 0.0.

The flexShrink parameter controls how much this item shrinks relative to its siblings when there is insufficient space in the main axis. A value of 0.0 means the item will not shrink. Default is 0.0.

The width and height parameters specify the preferred size of the item. If null, the size is determined by the item's content and flex properties.

The minWidth, maxWidth, minHeight, maxHeight parameters set size constraints for the item, preventing it from becoming smaller or larger than specified.

The aspectRatio parameter maintains the width/height ratio (width/height) if specified, potentially overriding explicit width/height values.

The top, left, bottom, right parameters are used for sticky positioning within the flex container, allowing the item to be offset from its normal position.

The alignSelf parameter overrides the parent's FlexBox.alignItems property for this individual item, controlling its alignment along the cross axis.

The paintOrder parameter controls the painting order of this item relative to its siblings. Items with lower values are painted behind items with higher values.

Example

FlexItem.builder(
  flexGrow: 1.0,
  builder: (context, layoutBox) {
    return Text('Size: ${layoutBox.size}');
  },
)

Implementation

const factory FlexItem.builder({
  Key? key,
  int? paintOrder,
  SizeUnit? width,
  SizeUnit? height,
  SizeUnit? minWidth,
  SizeUnit? maxWidth,
  SizeUnit? minHeight,
  SizeUnit? maxHeight,
  double flexGrow,
  double flexShrink,
  double? aspectRatio,
  PositionUnit? top,
  PositionUnit? left,
  PositionUnit? bottom,
  PositionUnit? right,
  BoxAlignmentGeometry? alignSelf,
  required Widget Function(BuildContext context, LayoutBox box) builder,
}) = BuilderFlexItem;