Flutter › Layout Widgets (Row, Column, Stack, Container)
How do mainAxisAlignment and crossAxisAlignment properly control the specific alignment of children within a Row or Column along each of those particular widget's own two genuinely separate distinct axes?
IntermediateAnswer
For a given Row, the main axis genuinely runs horizontally while the cross axis genuinely runs vertically, and vice versa for a Column, and mainAxisAlignment controls exactly how children are actually distributed along that particular main axis, such as evenly spacing them apart or centering them together, while crossAxisAlignment separately controls exactly how those same children are actually aligned along the considerably shorter perpendicular cross axis, such as stretching every child to properly fill that entire available cross axis space or simply aligning them all consistently to one particular specific side.
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [Icon(Icons.menu), Text('Title'), Icon(Icons.search)],
)Real-world example A custom app bar properly uses spaceBetween for its mainAxisAlignment to correctly push a menu icon and a search icon apart toward opposite edges while keeping the centered title text properly positioned directly in between them, and uses center for its crossAxisAlignment to correctly vertically align every one of those elements consistently.