FlexItem class abstract interface

A widget that configures flex properties for an individual child within a FlexBox.

FlexItem is used to wrap children of a FlexBox to specify how each child should behave within the flex layout. It provides control over sizing, positioning, flex behavior, and alignment for each individual item.

This widget works by attaching LayoutData to the child's ParentData, which the flex layout algorithm uses to determine how to size and position each child.

Example usage:

FlexBox(
  direction: FlexDirection.row,
  children: [
    FlexItem(
      flexGrow: 1.0,
      child: Container(color: Colors.red),
    ),
    FlexItem(
      width: SizeUnit.fixed(100),
      child: Container(color: Colors.blue),
    ),
  ],
)
Implemented types
Implementers
Available extensions

Constructors

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, PositionType? position, required Widget child})
Creates a flex item with a direct child widget and specified flex properties.
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, PositionType? position, required Widget builder(BuildContext context, LayoutBox box)})
Creates a flex item with a builder function for dynamic child construction.
const
factory

Properties

alignSelf BoxAlignmentGeometry?
The cross-axis alignment for this specific flex item.
no setter
asAbsoluteItem Widget

Available on Widget, provided by the WidgetExtension extension

Explicitly wraps this widget as an AbsoluteItem.
no setter
asFlexItem Widget

Available on Widget, provided by the WidgetExtension extension

Explicitly wraps this widget as a FlexItem.
no setter
aspectRatio double?
The aspect ratio constraint (width/height) for this item.
no setterinherited
bottom PositionUnit?
The offset from the bottom edge of the parent container.
no setterinherited
flexGrow double
The flex grow factor for this item.
no setter
flexShrink double
The flex shrink factor for this item.
no setter
hashCode int
The hash code for this object.
no setterinherited
height SizeUnit?
The preferred height of this item.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
left PositionUnit?
The offset from the left edge of the parent container.
no setterinherited
maxHeight SizeUnit?
The maximum height constraint for this item.
no setterinherited
maxWidth SizeUnit?
The maximum width constraint for this item.
no setterinherited
minHeight SizeUnit?
The minimum height constraint for this item.
no setterinherited
minWidth SizeUnit?
The minimum width constraint for this item.
no setterinherited
paintOrder int?
The paint order for this item, controlling drawing order when overlapping. Lower values are painted first (behind), higher values are painted last (on top).
no setterinherited
position PositionType?
The positioning type for this flex item.
no setter
The offset from the right edge of the parent container.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
top PositionUnit?
The offset from the top edge of the parent container.
no setterinherited
width SizeUnit?
The preferred width of this item.
no setterinherited

Methods

aspectRatio(double aspectRatio, [Key? key]) Widget

Available on Widget, provided by the WidgetExtension extension

Sets the aspect ratio constraint for this widget.
bottom(PositionUnit bottom, [Key? key]) Widget

Available on Widget, provided by the WidgetExtension extension

Sets the distance from the bottom edge of the parent container.
constrained({SizeUnit? minWidth, SizeUnit? maxWidth, SizeUnit? minHeight, SizeUnit? maxHeight, Key? key}) Widget

Available on Widget, provided by the WidgetExtension extension

Sets comprehensive size constraints including both minimum and maximum bounds.
createElement() Element
Inflates this configuration to a concrete instance.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
flexGrow(double flexGrow, [Key? key]) Widget

Available on Widget, provided by the WidgetExtension extension

Sets the flex grow factor for this widget within a flex container.
flexShrink(double flexShrink, [Key? key]) Widget

Available on Widget, provided by the WidgetExtension extension

Sets the flex shrink factor for this widget within a flex container.
height(SizeUnit height, [Key? key]) Widget

Available on Widget, provided by the WidgetExtension extension

Sets the height of this widget using a SizeUnit.
id(Object valueKey) Widget

Available on Widget, provided by the WidgetExtension extension

Assigns a ValueKey to this widget using the provided value.
key(Key key) Widget

Available on Widget, provided by the WidgetExtension extension

Assigns a Key to this widget.
left(PositionUnit left, [Key? key]) Widget

Available on Widget, provided by the WidgetExtension extension

Sets the distance from the left edge of the parent container.
maxHeight(SizeUnit maxHeight, [Key? key]) Widget

Available on Widget, provided by the WidgetExtension extension

Sets the maximum height constraint for this widget using a SizeUnit.
maxSized({SizeUnit? maxWidth, SizeUnit? maxHeight, Key? key}) Widget

Available on Widget, provided by the WidgetExtension extension

Sets maximum width and height constraints simultaneously.
maxWidth(SizeUnit maxWidth, [Key? key]) Widget

Available on Widget, provided by the WidgetExtension extension

Sets the maximum width constraint for this widget using a SizeUnit.
minHeight(SizeUnit minHeight, [Key? key]) Widget

Available on Widget, provided by the WidgetExtension extension

Sets the minimum height constraint for this widget using a SizeUnit.
minSized({SizeUnit? minWidth, SizeUnit? minHeight, Key? key}) Widget

Available on Widget, provided by the WidgetExtension extension

Sets minimum width and height constraints simultaneously.
minWidth(SizeUnit minWidth, [Key? key]) Widget

Available on Widget, provided by the WidgetExtension extension

Sets the minimum width constraint for this widget using a SizeUnit.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
paintOrder(int paintOrder, [Key? key]) Widget

Available on Widget, provided by the WidgetExtension extension

Sets the paint order for this widget within its parent container.
position(PositionType position, [Key? key]) Widget

Available on Widget, provided by the WidgetExtension extension

Sets the position type for this widget to control positioning context.
positioned({PositionUnit? top, PositionUnit? left, PositionUnit? bottom, PositionUnit? right, Key? key}) Widget

Available on Widget, provided by the WidgetExtension extension

Positions the widget using multiple edge offsets simultaneously.

Available on Widget, provided by the WidgetExtension extension

Sets the distance from the right edge of the parent container.
selfAligned(BoxAlignmentGeometry alignSelf, [Key? key]) Widget

Available on Widget, provided by the WidgetExtension extension

Sets the alignment of this widget within its parent flex container.
sized({SizeUnit? width, SizeUnit? height, Key? key}) Widget

Available on Widget, provided by the WidgetExtension extension

Sets both width and height dimensions simultaneously.
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
top(PositionUnit top, [Key? key]) Widget

Available on Widget, provided by the WidgetExtension extension

Sets the distance from the top edge of the parent container.
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited
width(SizeUnit width, [Key? key]) Widget

Available on Widget, provided by the WidgetExtension extension

Sets the width of this widget using a SizeUnit.

Operators

operator ==(Object other) bool
The equality operator.
inherited