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
Prop | Type | Required / Default Value |
---|---|---|
style | Style<FlexBoxSpec> | Optional, defaults to FlexBoxStyler.create() |
key | Key? | Optional |
children | List<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.
Method | Description |
---|---|
animate | Sets animation configuration |
alignment | Sets box alignment |
transformAlignment | Sets transform alignment |
clipBehavior | Sets clip behavior |
modifier | Adds widget modifiers |
flex | Sets flex properties |
foregroundDecoration | Sets foreground decoration |
padding | Sets padding |
margin | Sets margin |
transform | Sets transform matrix |
decoration | Sets decoration |
constraints | Sets box constraints |
borderRadius | Sets border radius |
border | Sets border |
direction | Sets flex direction |
mainAxisAlignment | Sets main axis alignment |
crossAxisAlignment | Sets cross axis alignment |
mainAxisSize | Sets main axis size |
verticalDirection | Sets vertical direction |
textDirection | Sets text direction |
textBaseline | Sets text baseline |
spacing | Sets spacing between children |
row | Sets direction to horizontal |
column | Sets direction to vertical |
paddingTop | Sets top padding |
paddingBottom | Sets bottom padding |
paddingLeft | Sets left padding |
paddingRight | Sets right padding |
paddingX | Sets horizontal padding |
paddingY | Sets vertical padding |
paddingAll | Sets padding on all sides |
paddingStart | Sets start padding (RTL-aware) |
paddingEnd | Sets end padding (RTL-aware) |
paddingOnly | Sets specific padding values |
marginTop | Sets top margin |
marginBottom | Sets bottom margin |
marginLeft | Sets left margin |
marginRight | Sets right margin |
marginX | Sets horizontal margin |
marginY | Sets vertical margin |
marginAll | Sets margin on all sides |
marginStart | Sets start margin (RTL-aware) |
marginEnd | Sets end margin (RTL-aware) |
marginOnly | Sets specific margin values |
width | Sets fixed width |
height | Sets fixed height |
minWidth | Sets minimum width |
maxWidth | Sets maximum width |
minHeight | Sets minimum height |
maxHeight | Sets maximum height |
size | Sets both width and height |
constraintsOnly | Sets specific constraints |
color | Sets background color |
gradient | Sets gradient background |
shadow | Sets single shadow |
shadows | Sets multiple shadows |
elevation | Sets Material elevation |
image | Sets background image |
shape | Sets shape |
borderTop | Sets top border |
borderBottom | Sets bottom border |
borderLeft | Sets left border |
borderRight | Sets right border |
borderStart | Sets start border (RTL-aware) |
borderEnd | Sets end border (RTL-aware) |
borderVertical | Sets top and bottom borders |
borderHorizontal | Sets left and right borders |
borderAll | Sets all borders |
borderRadiusAll | Sets radius on all corners |
borderRadiusTop | Sets radius on top corners |
borderRadiusBottom | Sets radius on bottom corners |
borderRadiusLeft | Sets radius on left corners |
borderRadiusRight | Sets radius on right corners |
borderRadiusTopLeft | Sets top-left radius |
borderRadiusTopRight | Sets top-right radius |
borderRadiusBottomLeft | Sets bottom-left radius |
borderRadiusBottomRight | Sets bottom-right radius |
borderRadiusTopStart | Sets top-start radius (RTL-aware) |
borderRadiusTopEnd | Sets top-end radius (RTL-aware) |
borderRadiusBottomStart | Sets bottom-start radius (RTL-aware) |
borderRadiusBottomEnd | Sets bottom-end radius (RTL-aware) |
borderRounded | Sets circular radius on all corners |
borderRoundedTop | Sets circular radius on top corners |
borderRoundedBottom | Sets circular radius on bottom corners |
borderRoundedLeft | Sets circular radius on left corners |
borderRoundedRight | Sets circular radius on right corners |
borderRoundedTopLeft | Sets circular top-left radius |
borderRoundedTopRight | Sets circular top-right radius |
borderRoundedBottomLeft | Sets circular bottom-left radius |
borderRoundedBottomRight | Sets circular bottom-right radius |
borderRoundedTopStart | Sets circular top-start radius (RTL-aware) |
borderRoundedTopEnd | Sets circular top-end radius (RTL-aware) |
borderRoundedBottomStart | Sets circular bottom-start radius (RTL-aware) |
borderRoundedBottomEnd | Sets circular bottom-end radius (RTL-aware) |
shadowOnly | Creates single shadow with parameters |
boxShadows | Sets multiple box shadows |
boxElevation | Sets Material elevation shadow |
rotate | Sets rotation transform |
scale | Sets scale transform |
translate | Sets translation transform |
skew | Sets skew transform |
transformReset | Resets transform to identity |