text
stringlengths 1
372
|
---|
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)), |
], |
); |
} |
} |
////////////////////////////////////////////////// |
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)), |
], |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.