text
stringlengths 0
197
|
---|
<topic_start> |
Example 19 |
<code_start> |
const Center( |
child: FittedBox( |
child: Text('Some Example Text.'), |
), |
) |
<code_end> |
But what happens if you put the FittedBox inside of a |
Center widget? The Center lets the FittedBox |
be any size it wants, up to the screen size. |
The FittedBox then sizes itself to the Text, |
and lets the Text be any size it wants. |
Since both FittedBox and the Text have the same size, |
no scaling happens. |
<topic_end> |
<topic_start> |
Example 20 |
<code_start> |
const Center( |
child: FittedBox( |
child: Text( |
'This is some very very very large text that is too big to fit a regular screen in a single line.'), |
), |
) |
<code_end> |
However, what happens if FittedBox is inside of a Center |
widget, but the Text is too large to fit the screen? |
FittedBox tries to size itself to the Text, |
but it can’t be bigger than the screen. |
It then assumes the screen size, |
and resizes Text so that it fits the screen, too. |
<topic_end> |
<topic_start> |
Example 21 |
<code_start> |
const Center( |
child: Text( |
'This is some very very very large text that is too big to fit a regular screen in a single line.'), |
) |
<code_end> |
If, however, you remove the FittedBox, the Text |
gets its maximum width from the screen, |
and breaks the line so that it fits the screen. |
<topic_end> |
<topic_start> |
Example 22 |
<code_start> |
FittedBox( |
child: Container( |
height: 20, |
width: double.infinity, |
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 ' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.