text
stringlengths
1
372
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,
),
),
),
flexible(
child: container(
color: green,
child: const text(
'goodbye!',
style: big,
),
),