text
stringlengths 1
372
|
---|
' width: double.infinity,\n' |
' height: double.infinity))'; |
@override |
final string explanation = |
'the screen forces the center to be exactly the same size as the screen, ' |
'so the center fills the screen.' |
'\n\n' |
'the center tells the container that it can be any size it wants, but not bigger than the screen.' |
'the container wants to be of infinite size, but since it can\'t be bigger than the screen, it just fills the screen.'; |
@override |
widget build(BuildContext context) { |
return center( |
child: container( |
width: double.infinity, height: double.infinity, color: red), |
); |
} |
} |
////////////////////////////////////////////////// |
class example6 extends example { |
const example6({super.key}); |
@override |
final code = 'center(child: container(color: red))'; |
@override |
final string explanation = |
'the screen forces the center to be exactly the same size as the screen, ' |
'so the center fills the screen.' |
'\n\n' |
'the center tells the container that it can be any size it wants, but not bigger than the screen.' |
'\n\n' |
'since the container has no child and no fixed size, it decides it wants to be as big as possible, so it fills the whole screen.' |
'\n\n' |
'but why does the container decide that? ' |
'simply because that\'s a design decision by those who created the container widget. ' |
'it could have been created differently, and you have to read the container documentation to understand how it behaves, depending on the circumstances. '; |
@override |
widget build(BuildContext context) { |
return center( |
child: container(color: red), |
); |
} |
} |
////////////////////////////////////////////////// |
class example7 extends example { |
const example7({super.key}); |
@override |
final code = 'center(\n' |
' child: container(color: red\n' |
' child: container(color: green, width: 30, height: 30)))'; |
@override |
final string explanation = |
'the screen forces the center to be exactly the same size as the screen, ' |
'so the center fills the screen.' |
'\n\n' |
'the center tells the red container that it can be any size it wants, but not bigger than the screen.' |
'since the red container has no size but has a child, it decides it wants to be the same size as its child.' |
'\n\n' |
'the red container tells its child that it can be any size it wants, but not bigger than the screen.' |
'\n\n' |
'the child is a green container that wants to be 30x30.' |
'\n\n' |
'since the red `container` has no size but has a child, it decides it wants to be the same size as its child. ' |
'the red color isn\'t visible, since the green container entirely covers all of the red container.'; |
@override |
widget build(BuildContext context) { |
return center( |
child: container( |
color: red, |
child: container(color: green, width: 30, height: 30), |
), |
); |
} |
} |
////////////////////////////////////////////////// |
class example8 extends example { |
const example8({super.key}); |
@override |
final code = 'center(\n' |
' child: container(color: red\n' |
' padding: const EdgeInsets.all(20),\n' |
' child: container(color: green, width: 30, height: 30)))'; |
@override |
final string explanation = |
'the red container sizes itself to its children size, but it takes its own padding into consideration. ' |
'so it is also 30x30 plus padding. ' |
'the red color is visible because of the padding, and the green container has the same size as in the previous example.'; |
@override |
widget build(BuildContext context) { |
return center( |
child: container( |
padding: const EdgeInsets.all(20), |
color: red, |
child: container(color: green, width: 30, height: 30), |
), |
); |
} |
} |
////////////////////////////////////////////////// |
class example9 extends example { |
const example9({super.key}); |
@override |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.