I see in the flutter layout docs the term 'cross axis' all over the place. Does this mean for a vertical layout scheme the horizontal axis is the cross axis, while in a horizontal one it's the vertical axis? Or is it more complicated than that?
For a column the main axis is vertical and the cross axis is horizontal (90° to the main axis). For a row the main axis is horizontal and the cross axis is vertical (90° to the main axis).
The cross axis in flexbox runs perpendicular to the main axis, therefore if your flex-direction is either row or row-reverse then the cross axis runs down the columns. If your main axis is column or column-reverse then the cross axis runs along the rows.
Using mainAxisAlignment in a Row lets you align the row's children horizontally (e.g. left, right). The cross axis to a Row 's main axis is vertical. So using crossAxisAlignment in a Row lets you define, how its children are aligned vertically.
Main Axis is vertical and the Cross Axis is horizontal. MainAxisAlignment aligns its children vertically and CrossAxisAlignment aligns horizontally in that Column. Column.
MainAxis
is the axis for the Widget in which it is supposed to scroll.
CrossAxis
is the one which is perpendicular to MainAxis.
For Row:
mainAxisAlignment
= Horizontal AxiscrossAxisAlignment
= Vertical Axis
For Column:
mainAxisAlignment
= Vertical AxiscrossAxisAlignment
= Horizontal Axis
Image source
For a column the main axis is vertical and the cross axis is horizontal (90° to the main axis).
For a row the main axis is horizontal and the cross axis is vertical (90° to the main axis).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With