text
stringlengths 1
372
|
|---|
example 18
|
<code_start>
|
const FittedBox(
|
child: Text('Some example text.'),
|
)
|
<code_end>
|
the screen forces the FittedBox to be exactly the same
|
size as the screen. the text has some natural width
|
(also called its intrinsic width) that depends on the
|
amount of text, its font size, and so on.
|
the FittedBox lets the text be any size it wants,
|
but after the text tells its size to the FittedBox,
|
the FittedBox scales the text until it fills all of
|
the available width.
|
<topic_end>
|
<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: [
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.