text
stringlengths 0
197
|
---|
@override
|
Widget build(BuildContext context) {
|
return ConstrainedBox(
|
constraints: const BoxConstraints(
|
minWidth: 70,
|
minHeight: 70,
|
maxWidth: 150,
|
maxHeight: 150,
|
),
|
child: Container(color: red, width: 10, height: 10),
|
);
|
}
|
}
|
class Example10 extends Example {
|
const Example10({super.key});
|
@override
|
final code = 'Center(\n'
|
' child: ConstrainedBox(\n'
|
' constraints: BoxConstraints(\n'
|
' minWidth: 70, minHeight: 70,\n'
|
' maxWidth: 150, maxHeight: 150),\n'
|
' child: Container(color: red, width: 10, height: 10))))';
|
@override
|
final String explanation =
|
'Now, Center allows ConstrainedBox to be any size up to the screen size.'
|
'\n\n'
|
'The 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 10 pixels, so it will end up having 70 (the MINIMUM).';
|
@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: 10, height: 10),
|
),
|
);
|
}
|
}
|
class Example11 extends Example {
|
const Example11({super.key});
|
@override
|
final code = 'Center(\n'
|
' child: ConstrainedBox(\n'
|
' constraints: BoxConstraints(\n'
|
' minWidth: 70, minHeight: 70,\n'
|
' maxWidth: 150, maxHeight: 150),\n'
|
' child: Container(color: red, width: 1000, height: 1000))))';
|
@override
|
final String explanation =
|
'Center allows ConstrainedBox to be any size up to the screen size.'
|
'The 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 1000 pixels, so it ends up having 150 (the MAXIMUM).';
|
@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: 1000, height: 1000),
|
),
|
);
|
}
|
}
|
class Example12 extends Example {
|
const Example12({super.key});
|
@override
|
final code = 'Center(\n'
|
' child: ConstrainedBox(\n'
|
' constraints: BoxConstraints(\n'
|
' minWidth: 70, minHeight: 70,\n'
|
' maxWidth: 150, maxHeight: 150),\n'
|
' child: Container(color: red, width: 100, height: 100))))';
|
@override
|
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.';
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.