FlexItem.builder constructor
- 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 builder(
- BuildContext context,
- 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;