Protected against bots by Yandex SmartCaptcha. Data processing policy
Flexible
Gives its child a share of the free space in a
Row
or
Column
. Unlike
Expanded
, the child
does not have to fill the allotted space
: with
fit:loose
(the default) it picks its own size, but no larger than its share.
Type:
single-child
Row
Flexible flex:2
ColoredBox color:#4f46e5
Center
Text "2×"
Flexible
ColoredBox color:#7c3aed
Center
Text "1×"
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
flex
|
int | 1 |
Weight: free space is divided between children in proportion to
flex
|
fit
|
string | loose |
loose
— the child may be smaller than its share;
tight
— it must fill it completely (this is how
Expanded
behaves)
|
Works
only
directly inside
Row
,
Column
or
Flex
.
Examples
A label that does not push the row apart
Long text shrinks and wraps without pushing the icon out; short text keeps its own size:
Row spacing:8
Icon star
Flexible
Text "A very long title that must not push neighbouring elements past the edge"
Icon chevron_right
Strict shares
SizedBox height:60
Row
Flexible flex:1 fit:tight
ColoredBox color:#4f46e5
Flexible flex:3 fit:tight
ColoredBox color:#059669
Differences between the app and the site
-
fit:tighton the site behaves likeExpanded: it grows by weight. -
fit:looseon the site does not grow : the child keeps its own size and can shrink, andflexdivides nothing.
Bad practices
Flexible outside Row/Column
// BAD — Flexible works only inside Row, Column or Flex
Padding
#padding all 8
Flexible
Text "Won't work"
// GOOD
Row
Flexible
Text "Works"
Best practices
- You need to fill all the remaining space — use Expanded , it is shorter and unambiguous.
-
You need long text to shrink and short text not to
— that is
Flexiblewithfit:loose. - An invisible spacer with a share — Spacer .