FlexBox constructor
const
FlexBox({
- Key? key,
- FlexDirection direction = FlexDirection.row,
- FlexWrap wrap = FlexWrap.none,
- int? maxItemsPerLine,
- int? maxLines,
- EdgeSpacingGeometry padding = EdgeSpacing.zero,
- SpacingUnit rowGap = SpacingUnit.zero,
- SpacingUnit columnGap = SpacingUnit.zero,
- BoxAlignmentGeometry alignItems = BoxAlignmentGeometry.start,
- BoxAlignmentContent alignContent = BoxAlignmentContent.start,
- BoxAlignmentBase justifyContent = BoxAlignmentBase.start,
- TextDirection? textDirection,
- bool reversePaint = false,
- ScrollController? verticalController,
- ScrollController? horizontalController,
- DiagonalDragBehavior diagonalDragBehavior = DiagonalDragBehavior.free,
- LayoutOverflow horizontalOverflow = LayoutOverflow.hidden,
- LayoutOverflow verticalOverflow = LayoutOverflow.hidden,
- TextBaseline? textBaseline,
- Clip clipBehavior = Clip.hardEdge,
- BorderRadiusGeometry? borderRadius,
- List<
Widget> children = const [],
Creates a flexible box layout container with the specified properties.
The children
parameter accepts a list of widgets to layout. For best results,
wrap each child in a FlexItem widget to control its flex behavior.
Example
FlexBox(
direction: FlexDirection.row,
wrap: FlexWrap.wrap,
alignItems: BoxAlignmentGeometry.center,
justifyContent: BoxAlignmentBase.spaceBetween,
padding: EdgeSpacing.all(SizeUnit.fixed(16)),
rowGap: SpacingUnit.fixed(8),
columnGap: SpacingUnit.fixed(8),
children: [
FlexItem(child: Text('Item 1')),
FlexItem(child: Text('Item 2')),
FlexItem(child: Text('Item 3')),
],
)
All parameters are optional except children
, which defaults to an empty list.
The layout will automatically adapt to the provided configuration.
Creates a FlexBox with the specified flex layout properties.
Implementation
const FlexBox({
super.key,
this.direction = FlexDirection.row,
this.wrap = FlexWrap.none,
this.maxItemsPerLine,
this.maxLines,
this.padding = EdgeSpacing.zero,
this.rowGap = SpacingUnit.zero,
this.columnGap = SpacingUnit.zero,
this.alignItems = BoxAlignmentGeometry.start,
this.alignContent = BoxAlignmentContent.start,
this.justifyContent = BoxAlignmentBase.start,
this.textDirection,
this.reversePaint = false,
this.verticalController,
this.horizontalController,
this.diagonalDragBehavior = DiagonalDragBehavior.free,
this.horizontalOverflow = LayoutOverflow.hidden,
this.verticalOverflow = LayoutOverflow.hidden,
this.textBaseline,
this.clipBehavior = Clip.hardEdge,
this.borderRadius,
this.children = const [],
});