text
stringlengths 1
372
|
---|
}); |
@override |
widget build(BuildContext context) { |
return TextButton( |
style: TextButton.styleFrom( |
foregroundColor: colors.white, |
backgroundColor: isSelected ? colors.grey : colors.grey[800], |
), |
child: Text(exampleNumber.toString()), |
onPressed: () { |
Scrollable.ensureVisible( |
context, |
duration: const duration(milliseconds: 350), |
curve: Curves.easeOut, |
alignment: 0.5, |
); |
onPressed(); |
}, |
); |
} |
} |
////////////////////////////////////////////////// |
class example1 extends example { |
const example1({super.key}); |
@override |
final code = 'container(color: red)'; |
@override |
final explanation = 'the screen is the parent of the container, ' |
'and it forces the container to be exactly the same size as the screen.' |
'\n\n' |
'so the container fills the screen and paints it red.'; |
@override |
widget build(BuildContext context) { |
return container(color: red); |
} |
} |
////////////////////////////////////////////////// |
class example2 extends example { |
const example2({super.key}); |
@override |
final code = 'container(width: 100, height: 100, color: red)'; |
@override |
final string explanation = |
'the red container wants to be 100x100, but it can\'t, ' |
'because the screen forces it to be exactly the same size as the screen.' |
'\n\n' |
'so the container fills the screen.'; |
@override |
widget build(BuildContext context) { |
return container(width: 100, height: 100, color: red); |
} |
} |
////////////////////////////////////////////////// |
class example3 extends example { |
const example3({super.key}); |
@override |
final code = 'center(\n' |
' child: container(width: 100, height: 100, 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.' |
'now the container can indeed be 100x100.'; |
@override |
widget build(BuildContext context) { |
return center( |
child: container(width: 100, height: 100, color: red), |
); |
} |
} |
////////////////////////////////////////////////// |
class example4 extends example { |
const example4({super.key}); |
@override |
final code = 'align(\n' |
' alignment: Alignment.bottomRight,\n' |
' child: container(width: 100, height: 100, color: red))'; |
@override |
final string explanation = |
'this is different from the previous example in that it uses align instead of center.' |
'\n\n' |
'align also tells the container that it can be any size it wants, but if there is empty space it won\'t center the container. ' |
'instead, it aligns the container to the bottom-right of the available space.'; |
@override |
widget build(BuildContext context) { |
return align( |
alignment: Alignment.bottomRight, |
child: container(width: 100, height: 100, color: red), |
); |
} |
} |
////////////////////////////////////////////////// |
class example5 extends example { |
const example5({super.key}); |
@override |
final code = 'center(\n' |
' child: container(\n' |
' color: red,\n' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.