text
stringlengths 0
197
|
---|
child: Container(color: red, width: 10, height: 10), |
) |
<code_end> |
You might guess that the Container has to be |
between 70 and 150 pixels, but you would be wrong. |
The ConstrainedBox only imposes additional constraints |
from those it receives from its parent. |
Here, the screen forces the ConstrainedBox to be exactly |
the same size as the screen, so it tells its child Container |
to also assume the size of the screen, thus ignoring its |
constraints parameter. |
<topic_end> |
<topic_start> |
Example 10 |
<code_start> |
Center( |
child: ConstrainedBox( |
constraints: const BoxConstraints( |
minWidth: 70, |
minHeight: 70, |
maxWidth: 150, |
maxHeight: 150, |
), |
child: Container(color: red, width: 10, height: 10), |
), |
) |
<code_end> |
Now, Center allows ConstrainedBox to be any size up to |
the screen size. The ConstrainedBox imposes additional |
constraints from its constraints parameter onto its child. |
The Container must be between 70 and 150 pixels. |
It wants to have 10 pixels, |
so it ends up having 70 (the minimum). |
<topic_end> |
<topic_start> |
Example 11 |
<code_start> |
Center( |
child: ConstrainedBox( |
constraints: const BoxConstraints( |
minWidth: 70, |
minHeight: 70, |
maxWidth: 150, |
maxHeight: 150, |
), |
child: Container(color: red, width: 1000, height: 1000), |
), |
) |
<code_end> |
Center allows ConstrainedBox to be any size up to the |
screen size. The ConstrainedBox imposes additional |
constraints from its constraints parameter onto its child. |
The Container must be between 70 and 150 pixels. |
It wants to have 1000 pixels, |
so it ends up having 150 (the maximum). |
<topic_end> |
<topic_start> |
Example 12 |
<code_start> |
Center( |
child: ConstrainedBox( |
constraints: const BoxConstraints( |
minWidth: 70, |
minHeight: 70, |
maxWidth: 150, |
maxHeight: 150, |
), |
child: Container(color: red, width: 100, height: 100), |
), |
) |
<code_end> |
Center allows ConstrainedBox to be any size up to the |
screen size. The ConstrainedBox imposes additional |
constraints from its constraints parameter onto its child. |
The Container must be between 70 and 150 pixels. |
It wants to have 100 pixels, and that’s the size it has, |
since that’s between 70 and 150. |
<topic_end> |
<topic_start> |
Example 13 |
<code_start> |
UnconstrainedBox( |
child: Container(color: red, width: 20, height: 50), |
) |
<code_end> |
The screen forces the UnconstrainedBox to be exactly |
the same size as the screen. However, the UnconstrainedBox |
lets its child Container be any size it wants. |
<topic_end> |
<topic_start> |
Example 14 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.