text
stringlengths 0
197
|
---|
children: [ |
Center(child: Text(code)), |
const SizedBox(height: 15), |
Text( |
explanation, |
style: TextStyle( |
color: Colors.blue[900], |
fontStyle: FontStyle.italic), |
), |
], |
), |
), |
), |
), |
), |
], |
), |
), |
), |
), |
), |
); |
} |
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); |
} |
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.