text
stringlengths 0
197
|
---|
), |
), |
), |
Expanded( |
child: Container( |
color: green, |
child: const Text( |
'Goodbye!', |
style: big, |
), |
), |
), |
], |
); |
} |
} |
class Example27 extends Example { |
const Example27({super.key}); |
@override |
final code = 'Row(children:[\n' |
' Flexible(\n' |
' child: Container(color: red, child: Text(\'…\')))\n' |
' Flexible(\n' |
' child: Container(color: green, child: Text(\'Goodbye!\'))]'; |
@override |
final String explanation = |
'The only difference if you use Flexible instead of Expanded, ' |
'is that Flexible lets its child be SMALLER than the Flexible width, ' |
'while Expanded forces its child to have the same width of the Expanded.' |
'\n\n' |
'But both Expanded and Flexible ignore their children\'s width when sizing themselves.' |
'\n\n' |
'This means that it\'s IMPOSSIBLE to expand Row children proportionally to their sizes. ' |
'The Row either uses the exact child\'s width, or ignores it completely when you use Expanded or Flexible.'; |
@override |
Widget build(BuildContext context) { |
return 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, |
), |
), |
), |
], |
); |
} |
} |
class Example28 extends Example { |
const Example28({super.key}); |
@override |
final code = 'Scaffold(\n' |
' body: Container(color: blue,\n' |
' child: Column(\n' |
' children: [\n' |
' Text(\'Hello!\'),\n' |
' Text(\'Goodbye!\')])))'; |
@override |
final String explanation = |
'The screen forces the Scaffold to be exactly the same size as the screen, ' |
'so the Scaffold fills the screen.' |
'\n\n' |
'The Scaffold tells the Container that it can be any size it wants, but not bigger than the screen.' |
'\n\n' |
'When a widget tells its child that it can be smaller than a certain size, ' |
'we say the widget supplies "loose" constraints to its child. More on that later.'; |
@override |
Widget build(BuildContext context) { |
return Scaffold( |
body: Container( |
color: blue, |
child: const Column( |
children: [ |
Text('Hello!'), |
Text('Goodbye!'), |
], |
), |
), |
); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.