text
stringlengths 1
474
|
|---|
),
|
),
|
),
|
),
|
),
|
],
|
),
|
),
|
),
|
),
|
),
|
);
|
}
|
Widget button(int exampleNumber) {
|
return Button(
|
key: ValueKey('button$exampleNumber'),
|
isSelected: count == exampleNumber,
|
exampleNumber: exampleNumber,
|
onPressed: () {
|
showExample(
|
exampleNumber,
|
widget.examples[exampleNumber - 1].code,
|
widget.examples[exampleNumber - 1].explanation,
|
);
|
},
|
);
|
}
|
void showExample(int exampleNumber, String code, String explanation) {
|
setState(() {
|
count = exampleNumber;
|
this.code = code;
|
this.explanation = explanation;
|
});
|
}
|
}
|
//////////////////////////////////////////////////
|
class Button extends StatelessWidget {
|
final bool isSelected;
|
final int exampleNumber;
|
final VoidCallback onPressed;
|
const Button({
|
super.key,
|
required this.isSelected,
|
required this.exampleNumber,
|
required this.onPressed,
|
});
|
@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});
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.