text
stringlengths 0
197
|
---|
}
|
}
|
class Example24 extends Example {
|
const Example24({super.key});
|
@override
|
final code = 'Row(children:[\n'
|
' Container(color: red, child: Text(\'…\'))\n'
|
' Container(color: green, child: Text(\'Goodbye!\'))]';
|
@override
|
final String explanation =
|
'Since the 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".';
|
@override
|
Widget build(BuildContext context) {
|
return 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)),
|
],
|
);
|
}
|
}
|
class Example25 extends Example {
|
const Example25({super.key});
|
@override
|
final code = 'Row(children:[\n'
|
' Expanded(\n'
|
' child: Container(color: red, child: Text(\'…\')))\n'
|
' Container(color: green, child: Text(\'Goodbye!\'))]';
|
@override
|
final String explanation =
|
'When a Row\'s child is wrapped in an Expanded widget, the Row won\'t let this child define its own width anymore.'
|
'\n\n'
|
'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.'
|
'\n\n'
|
'In other words, once you use Expanded, the original child\'s width becomes irrelevant, and is ignored.';
|
@override
|
Widget build(BuildContext context) {
|
return 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)),
|
],
|
);
|
}
|
}
|
class Example26 extends Example {
|
const Example26({super.key});
|
@override
|
final code = 'Row(children:[\n'
|
' Expanded(\n'
|
' child: Container(color: red, child: Text(\'…\')))\n'
|
' Expanded(\n'
|
' child: Container(color: green, child: Text(\'Goodbye!\'))]';
|
@override
|
final String explanation =
|
'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.'
|
'\n\n'
|
'In other words, Expanded ignores the preferred width of its children.';
|
@override
|
Widget build(BuildContext context) {
|
return Row(
|
children: [
|
Expanded(
|
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.