Protected against bots by Yandex SmartCaptcha. Data processing policy
Row
A horizontal container — lays its children out from left to right.
Type:
multi-child
Row spacing:12
Icon home
Text "Home"
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
alignment
|
string | start |
Alignment along the main axis:
start
,
end
,
center
,
spaceBetween
,
spaceAround
,
spaceEvenly
|
size
|
string | max |
Size along the main axis:
min
,
max
|
crossAlignment
|
string | center |
Alignment along the cross axis:
start
,
end
,
center
,
stretch
,
baseline
|
textDirection
|
string | — |
Text direction:
ltr
,
rtl
|
textBaseline
|
string | — |
Text baseline:
alphabetic
,
ideographic
|
spacing
|
double | 0 | Gap between children |
Examples
A centered row
Row mainAxisAlignment:center spacing:8
Icon star color:#FFD700
Text "4.8"
Buttons on the right
Row mainAxisAlignment:end spacing:12
ElevatedButton onPressed:"navigate:/settings"
Text "Settings"
ElevatedButton onPressed:"navigate:/profile"
Text "Profile"
A title with Expanded
Row crossAxisAlignment:center spacing:16
Expanded
Text "A long title" maxLines:1 overflow:ellipsis
Icon arrow_forward_ios size:16
Best practices
size:min
inside scroll views
By default Row has
mainAxisSize:max
— it tries to take all the available space along the main axis. Inside a horizontal scroll view (
CustomScrollView scrollDirection:horizontal
) that space is infinite: "take everything" is impossible, and there is no "remaining" space to share between
Expanded
and
Spacer
. A Row with a flexible child inside such a scroll view is a layout error.
Inside a horizontal scroll view write
size:min
and do not put
Expanded
/
Spacer
along the horizontal axis:
// BAD — Spacer asks for "the remaining space", and in a scroll view it is infinite
CustomScrollView scrollDirection:horizontal
Row spacing:12
Icon home
Spacer
Text "Home"
// GOOD — Row takes the width of its children
CustomScrollView scrollDirection:horizontal
Row spacing:12 size:min
Icon home
Text "Home"