FlexItem constructor

const FlexItem({
  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 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;