text
stringlengths 1
474
|
---|
color: Colors.red, |
), |
)<code_end> |
FittedBox can only scale a widget that is bounded |
(has non-infinite width and height). Otherwise, |
it won’t render anything, |
and you’ll see an error in the console.<topic_end> |
<topic_start>Example 23 |
<code_start>Row( |
children: [ |
Container(color: red, child: const Text('Hello!', style: big)), |
Container(color: green, child: const Text('Goodbye!', style: big)), |
], |
)<code_end> |
The screen forces the Row to be exactly the same size |
as the screen.Just like an UnconstrainedBox, the Row won’t |
impose any constraints onto its children, |
and instead lets them be any size they want. |
The Row then puts them side-by-side, |
and any extra space remains empty.<topic_end> |
<topic_start>Example 24 |
<code_start>Row( |
children: [ |
Container( |
color: red, |
child: const Text( |
'This is a very long text that ' |
'won\'t fit the line.', |
style: big, |
), |
), |
Container(color: green, child: const Text('Goodbye!', style: big)), |
], |
)<code_end> |
Since Row won’t impose any constraints onto its children, |
it’s quite possible that the children might be too big to fit |
the available width of the Row. In this case, just like an |
UnconstrainedBox, the Row displays the “overflow warning”.<topic_end> |
<topic_start>Example 25 |
<code_start>Row( |
children: [ |
Expanded( |
child: Center( |
child: Container( |
color: red, |
child: const Text( |
'This is a very long text that won\'t fit the line.', |
style: big, |
), |
), |
), |
), |
Container(color: green, child: const Text('Goodbye!', style: big)), |
], |
)<code_end> |
When a Row’s child is wrapped in an Expanded widget, |
the Row won’t let this child define its own width anymore.Instead, it defines the Expanded width according to the |
other children, and only then the Expanded widget forces |
the original child to have the Expanded’s width.In other words, once you use Expanded, |
the original child’s width becomes irrelevant, and is ignored.<topic_end> |
<topic_start>Example 26 |
<code_start>Row( |
children: [ |
Expanded( |
child: Container( |
color: red, |
child: const Text( |
'This is a very long text that won\'t fit the line.', |
style: big, |
), |
), |
), |
Expanded( |
child: Container( |
color: green, |
child: const Text( |
'Goodbye!', |
style: big, |
), |
), |
), |
], |
)<code_end> |
If all of Row’s children are wrapped in Expanded widgets, |
each Expanded has a size proportional to its flex parameter, |
and only then each Expanded widget forces its child to have |
the Expanded’s width.In other words, Expanded ignores the preferred width of |
its children.<topic_end> |
<topic_start>Example 27 |
<code_start>Row( |
children: [ |
Flexible( |
child: Container( |
color: red, |
child: const Text( |
'This is a very long text that won\'t fit the line.', |
style: big, |
), |
), |
), |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.