text
stringlengths 1
372
|
---|
final string explanation = |
'center allows ConstrainedBox to be any size up to the screen size.' |
'constrainedbox imposes ADDITIONAL constraints from its \'constraints\' parameter onto its child.' |
'\n\n' |
'the container must be between 70 and 150 pixels. it wants to have 100 pixels, and that\'s the size it has, since that\'s between 70 and 150.'; |
@override |
widget build(BuildContext context) { |
return center( |
child: ConstrainedBox( |
constraints: const BoxConstraints( |
minWidth: 70, |
minHeight: 70, |
maxWidth: 150, |
maxHeight: 150, |
), |
child: container(color: red, width: 100, height: 100), |
), |
); |
} |
} |
////////////////////////////////////////////////// |
class example13 extends example { |
const example13({super.key}); |
@override |
final code = 'unconstrainedbox(\n' |
' child: container(color: red, width: 20, height: 50));'; |
@override |
final string explanation = |
'the screen forces the UnconstrainedBox to be exactly the same size as the screen.' |
'however, the UnconstrainedBox lets its child container be any size it wants.'; |
@override |
widget build(BuildContext context) { |
return UnconstrainedBox( |
child: container(color: red, width: 20, height: 50), |
); |
} |
} |
////////////////////////////////////////////////// |
class example14 extends example { |
const example14({super.key}); |
@override |
final code = 'unconstrainedbox(\n' |
' child: container(color: red, width: 4000, height: 50));'; |
@override |
final string explanation = |
'the screen forces the UnconstrainedBox to be exactly the same size as the screen, ' |
'and UnconstrainedBox lets its child container be any size it wants.' |
'\n\n' |
'unfortunately, in this case the container has 4000 pixels of width and is too big to fit in the UnconstrainedBox, ' |
'so the UnconstrainedBox displays the much dreaded "overflow warning".'; |
@override |
widget build(BuildContext context) { |
return UnconstrainedBox( |
child: container(color: red, width: 4000, height: 50), |
); |
} |
} |
////////////////////////////////////////////////// |
class example15 extends example { |
const example15({super.key}); |
@override |
final code = 'overflowbox(\n' |
' minWidth: 0,' |
' minHeight: 0,' |
' maxWidth: double.infinity,' |
' maxHeight: double.infinity,' |
' child: container(color: red, width: 4000, height: 50));'; |
@override |
final string explanation = |
'the screen forces the OverflowBox to be exactly the same size as the screen, ' |
'and OverflowBox lets its child container be any size it wants.' |
'\n\n' |
'overflowbox is similar to UnconstrainedBox, and the difference is that it won\'t display any warnings if the child doesn\'t fit the space.' |
'\n\n' |
'in this case the container is 4000 pixels wide, and is too big to fit in the OverflowBox, ' |
'but the OverflowBox simply shows as much as it can, with no warnings given.'; |
@override |
widget build(BuildContext context) { |
return OverflowBox( |
minWidth: 0, |
minHeight: 0, |
maxWidth: double.infinity, |
maxHeight: double.infinity, |
child: container(color: red, width: 4000, height: 50), |
); |
} |
} |
////////////////////////////////////////////////// |
class example16 extends example { |
const example16({super.key}); |
@override |
final code = 'unconstrainedbox(\n' |
' child: container(color: colors.red, width: double.infinity, height: 100));'; |
@override |
final string explanation = |
'this won\'t render anything, and you\'ll see an error in the console.' |
'\n\n' |
'the UnconstrainedBox lets its child be any size it wants, ' |
'however its child is a container with infinite size.' |
'\n\n' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.