text
stringlengths 0
197
|
---|
A loose constraint is one that has a minimum
|
of zero and a maximum non-zero.
|
Some boxes loosen the incoming constraints,
|
meaning the maximum is maintained but the
|
minimum is removed, so the widget can have
|
a minimum width and height both equal to zero.
|
Ultimately, Center’s purpose is to transform
|
the tight constraints it received from its parent
|
(the screen) to loose constraints for its child
|
(the Container).
|
If you revisit Example 3,
|
the Center allows the red Container to be smaller,
|
but not bigger than the screen.
|
<topic_end>
|
<topic_start>
|
Unbounded constraints
|
info Note
|
You might be directed here if the framework
|
detects a problem involving box constraints.
|
The Flex section below might also apply.
|
In certain situations,
|
a box’s constraint is unbounded, or infinite.
|
This means that either the maximum width or
|
the maximum height is set to double.infinity.
|
A box that tries to be as big as possible won’t
|
function usefully when given an unbounded constraint and,
|
in debug mode, throws an exception.
|
The most common case where a render box ends up
|
with an unbounded constraint is within a flex box
|
(Row or Column),
|
and within a scrollable region
|
(such as ListView and other ScrollView subclasses).
|
ListView, for example,
|
tries to expand to fit the space available
|
in its cross-direction
|
(perhaps it’s a vertically-scrolling block and
|
tries to be as wide as its parent).
|
If you nest a vertically scrolling ListView
|
inside a horizontally scrolling ListView,
|
the inner list tries to be as wide as possible,
|
which is infinitely wide,
|
since the outer one is scrollable in that direction.
|
The next section describes the error you might
|
encounter with unbounded constraints in a Flex widget.
|
<topic_end>
|
<topic_start>
|
Flex
|
A flex box (Row and Column) behaves
|
differently depending on whether its
|
constraint is bounded or unbounded in
|
its primary direction.
|
A flex box with a bounded constraint in its
|
primary direction tries to be as big as possible.
|
A flex box with an unbounded constraint
|
in its primary direction tries to fit its children
|
in that space. Each child’s flex value must be
|
set to zero, meaning that you can’t use
|
Expanded when the flex box is inside
|
another flex box or a scrollable;
|
otherwise it throws an exception.
|
The cross direction
|
(width for Column or height for Row),
|
must never be unbounded,
|
or it can’t reasonably align its children.
|
<topic_end>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.