1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 13:58:47 +00:00

Migrate to the New Material Buttons (#668)

This commit is contained in:
Brett Morgan
2021-01-27 13:20:50 +11:00
committed by GitHub
parent 6502209a78
commit 622e8d55d3
44 changed files with 122 additions and 107 deletions

View File

@@ -43,7 +43,7 @@ class _AddButton extends StatelessWidget {
(cart) => cart.items.contains(item),
);
return FlatButton(
return TextButton(
onPressed: isInCart
? null
: () {
@@ -54,7 +54,14 @@ class _AddButton extends StatelessWidget {
var cart = context.read<CartModel>();
cart.add(item);
},
splashColor: Theme.of(context).primaryColor,
style: ButtonStyle(
overlayColor: MaterialStateProperty.resolveWith<Color>((states) {
if (states.contains(MaterialState.pressed)) {
return Theme.of(context).primaryColor;
}
return null; // Defer to the widget's default.
}),
),
child: isInCart ? Icon(Icons.check, semanticLabel: 'ADDED') : Text('ADD'),
);
}