update example app's color & pop up menu

null_safety
小赖 4 years ago
parent 6014f3796a
commit e85c4d9628

@ -10,6 +10,7 @@ class ExamplePopUpMenu extends StatefulWidget {
} }
class _ExamplePopUpMenuState extends State<ExamplePopUpMenu> { class _ExamplePopUpMenuState extends State<ExamplePopUpMenu> {
int _value;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ASScaffold( return ASScaffold(
@ -22,18 +23,23 @@ class _ExamplePopUpMenuState extends State<ExamplePopUpMenu> {
trailing: Builder( trailing: Builder(
builder: (context) { builder: (context) {
return TextButton( return TextButton(
child: 'test'.text.make(), child: '$_value'.text.make(),
onPressed: () { onPressed: () async {
showASPopUpMenu<int>( int result = await showASPopUpMenu<int>(
context: context, context: context,
initValue: 3, initValue: _value,
items: [ items: List.generate(
PopupMenuItem(child: 'test'.text.make(), value: 1), 20,
PopupMenuItem(child: 'test'.text.make(), value: 2), (index) => PopupMenuItem(
PopupMenuItem(child: 'test'.text.make(), value: 3), child: '$index'.text.isIntrinsic.make(),
PopupMenuItem(child: 'test'.text.make(), value: 4), value: index,
], ),
).then((value) {}); ),
);
if (result != null)
setState(() {
_value = result;
});
}, },
); );
}, },

@ -13,7 +13,19 @@ class ExampleStyleColor extends StatefulWidget {
class _ExampleStyleColorState extends State<ExampleStyleColor> { class _ExampleStyleColorState extends State<ExampleStyleColor> {
_buildCard(ColorObject object) { _buildCard(ColorObject object) {
return ListTile( return ListTile(
title: Text('${object.name} ${object.color.toString().substring(6, 16)}'), title: Text(
'${object.name} ${object.color.toString().substring(6, 16)}',
style: TextStyle(
color: object.color,
shadows: [
Shadow(
color: Colors.black54,
offset: Offset.zero,
blurRadius: 2,
),
],
),
),
subtitle: Text(object.codeName), subtitle: Text(object.codeName),
trailing: Card( trailing: Card(
color: object.color, color: object.color,

Loading…
Cancel
Save