Column
Creates a vertical layout that arranges children from top to bottom.
Basic Usage
Column([]any{
Text("First"),
Text("Second"),
Text("Third"),
})
Options
| Option |
Type |
Description |
Example |
Spacing |
float32 |
Sets the space between children in dp (default: 8) |
Spacing(16) |
MainAxis |
MainAxisAlignment |
Sets alignment along the vertical axis |
MainAxis(MainAxisCenter) |
Main Axis Alignment Values
| Value |
Description |
MainAxisStart |
Align children to the top (default) |
MainAxisCenter |
Center children vertically |
MainAxisEnd |
Align children to the bottom |
MainAxisSpaceBetween |
Distribute space between children |
MainAxisSpaceAround |
Distribute space around children |
MainAxisSpaceEvenly |
Distribute space evenly |
Examples
// Basic column with default spacing
Column([]any{
Text("Item 1"),
Text("Item 2"),
Text("Item 3"),
})
// Column with custom spacing
Column([]any{
Text("Item 1"),
Text("Item 2"),
}, Spacing(24))
// Column with no spacing
Column([]any{
Text("Item 1"),
Text("Item 2"),
}, Spacing(0))
// Column with centered alignment
Column([]any{
Text("Centered"),
Button("Action"),
}, MainAxis(MainAxisCenter))
// Column with flexible children using Spacer
Column([]any{
Text("Top"),
Spacer(),
Text("Bottom"),
})
// Column with Expanded widget
Column([]any{
Text("Header"),
Expanded(ScrollView(content)),
Text("Footer"),
})