FlexItem 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 child,
Creates a flex item with a direct child widget and specified flex properties.
The child
parameter is required and specifies the widget to be laid out
within the flex container.
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(
flexGrow: 1.0,
alignSelf: BoxAlignmentGeometry.center,
child: Text('Flexible content'),
)
Implementation
const factory FlexItem({
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 child,
}) = DirectFlexItem;