Skip to Content
Mix 2.0 is in development! You can access the Mix 1.0 docs here.

FlexBox

This is equivalent to the Flex wrapped in Container widgets in Flutter. Everything you can do with the Box widget, you can also do with FlexBox. However, the main difference is that you can specify flex attributes for it.

FlexBox( style: FlexBoxStyler() .color(Colors.blue) .direction(Axis.horizontal) .mainAxisAlignment(MainAxisAlignment.spaceBetween), children: [ Box(child: Text('Box 1')), Box(child: Text('Box 2')), Box(child: Text('Box 3')), ], );

RowBox and ColumnBox

If you want to quickly set the direction of your flex container, you can use RowBox or ColumnBox. These widgets work just like Flutter’s Row and Column, but with the added bonus that you can style them using all the same options as Box. This makes them perfect when you want to lock in a horizontal or vertical layout and still take advantage of powerful styling features.

RowBox( style: FlexBoxStyler() .color(Colors.blue) .mainAxisAlignment(MainAxisAlignment.spaceBetween), children: [...], );
ColumnBox( style: FlexBoxStyler() .color(Colors.blue) .mainAxisAlignment(MainAxisAlignment.spaceBetween), children: [...], );

Constructor

PropTypeRequired / Default Value
styleStyle<FlexBoxSpec>Optional, defaults to FlexBoxStyler.create()
keyKey?Optional
childrenList<Widget>Optional, defaults to const <Widget>[]

Style API Reference

Mix provides an extension of Style<FlexBoxSpec> called FlexBoxStyler for easily styling FlexBox, RowBox, and ColumnBox widgets.

MethodDescription
animateSets animation configuration
alignmentSets box alignment
transformAlignmentSets transform alignment
clipBehaviorSets clip behavior
modifierAdds widget modifiers
flexSets flex properties
foregroundDecorationSets foreground decoration
paddingSets padding
marginSets margin
transformSets transform matrix
decorationSets decoration
constraintsSets box constraints
borderRadiusSets border radius
borderSets border
directionSets flex direction
mainAxisAlignmentSets main axis alignment
crossAxisAlignmentSets cross axis alignment
mainAxisSizeSets main axis size
verticalDirectionSets vertical direction
textDirectionSets text direction
textBaselineSets text baseline
spacingSets spacing between children
rowSets direction to horizontal
columnSets direction to vertical
paddingTopSets top padding
paddingBottomSets bottom padding
paddingLeftSets left padding
paddingRightSets right padding
paddingXSets horizontal padding
paddingYSets vertical padding
paddingAllSets padding on all sides
paddingStartSets start padding (RTL-aware)
paddingEndSets end padding (RTL-aware)
paddingOnlySets specific padding values
marginTopSets top margin
marginBottomSets bottom margin
marginLeftSets left margin
marginRightSets right margin
marginXSets horizontal margin
marginYSets vertical margin
marginAllSets margin on all sides
marginStartSets start margin (RTL-aware)
marginEndSets end margin (RTL-aware)
marginOnlySets specific margin values
widthSets fixed width
heightSets fixed height
minWidthSets minimum width
maxWidthSets maximum width
minHeightSets minimum height
maxHeightSets maximum height
sizeSets both width and height
constraintsOnlySets specific constraints
colorSets background color
gradientSets gradient background
shadowSets single shadow
shadowsSets multiple shadows
elevationSets Material elevation
imageSets background image
shapeSets shape
borderTopSets top border
borderBottomSets bottom border
borderLeftSets left border
borderRightSets right border
borderStartSets start border (RTL-aware)
borderEndSets end border (RTL-aware)
borderVerticalSets top and bottom borders
borderHorizontalSets left and right borders
borderAllSets all borders
borderRadiusAllSets radius on all corners
borderRadiusTopSets radius on top corners
borderRadiusBottomSets radius on bottom corners
borderRadiusLeftSets radius on left corners
borderRadiusRightSets radius on right corners
borderRadiusTopLeftSets top-left radius
borderRadiusTopRightSets top-right radius
borderRadiusBottomLeftSets bottom-left radius
borderRadiusBottomRightSets bottom-right radius
borderRadiusTopStartSets top-start radius (RTL-aware)
borderRadiusTopEndSets top-end radius (RTL-aware)
borderRadiusBottomStartSets bottom-start radius (RTL-aware)
borderRadiusBottomEndSets bottom-end radius (RTL-aware)
borderRoundedSets circular radius on all corners
borderRoundedTopSets circular radius on top corners
borderRoundedBottomSets circular radius on bottom corners
borderRoundedLeftSets circular radius on left corners
borderRoundedRightSets circular radius on right corners
borderRoundedTopLeftSets circular top-left radius
borderRoundedTopRightSets circular top-right radius
borderRoundedBottomLeftSets circular bottom-left radius
borderRoundedBottomRightSets circular bottom-right radius
borderRoundedTopStartSets circular top-start radius (RTL-aware)
borderRoundedTopEndSets circular top-end radius (RTL-aware)
borderRoundedBottomStartSets circular bottom-start radius (RTL-aware)
borderRoundedBottomEndSets circular bottom-end radius (RTL-aware)
shadowOnlyCreates single shadow with parameters
boxShadowsSets multiple box shadows
boxElevationSets Material elevation shadow
rotateSets rotation transform
scaleSets scale transform
translateSets translation transform
skewSets skew transform
transformResetResets transform to identity