text
stringlengths 0
197
|
---|
); |
} |
} |
class Example20 extends Example { |
const Example20({super.key}); |
@override |
final code = 'Center(\n' |
' child: FittedBox(\n' |
' child: Text(\'…\')));'; |
@override |
final String explanation = |
'However, what happens if FittedBox is inside of a Center widget, but the Text is too large to fit the screen?' |
'\n\n' |
'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.'; |
@override |
Widget build(BuildContext context) { |
return 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.'), |
), |
); |
} |
} |
class Example21 extends Example { |
const Example21({super.key}); |
@override |
final code = 'Center(\n' |
' child: Text(\'…\'));'; |
@override |
final String explanation = '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.'; |
@override |
Widget build(BuildContext context) { |
return 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.'), |
); |
} |
} |
class Example22 extends Example { |
const Example22({super.key}); |
@override |
final code = 'FittedBox(\n' |
' child: Container(\n' |
' height: 20, width: double.infinity));'; |
@override |
final String explanation = |
'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.'; |
@override |
Widget build(BuildContext context) { |
return FittedBox( |
child: Container( |
height: 20, |
width: double.infinity, |
color: Colors.red, |
), |
); |
} |
} |
class Example23 extends Example { |
const Example23({super.key}); |
@override |
final code = 'Row(children:[\n' |
' Container(color: red, child: Text(\'Hello!\'))\n' |
' Container(color: green, child: Text(\'Goodbye!\'))]'; |
@override |
final String explanation = |
'The screen forces the Row to be exactly the same size as the screen.' |
'\n\n' |
'Just like an UnconstrainedBox, the Row won\'t impose any constraints onto its children, ' |
'and instead lets them be any size they want.' |
'\n\n' |
'The Row then puts them side-by-side, and any extra space remains empty.'; |
@override |
Widget build(BuildContext context) { |
return Row( |
children: [ |
Container(color: red, child: const Text('Hello!', style: big)), |
Container(color: green, child: const Text('Goodbye!', style: big)), |
], |
); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.