mirror of
https://github.com/flutter/samples.git
synced 2026-03-31 00:33:02 +00:00
Upgrading samples to flutter_lints, part 1 of n (#804)
This commit is contained in:
@@ -13,7 +13,7 @@ class FavoritesPage extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Favorites'),
|
||||
title: const Text('Favorites'),
|
||||
),
|
||||
body: Consumer<Favorites>(
|
||||
builder: (context, value, child) => value.items.isNotEmpty
|
||||
@@ -23,7 +23,7 @@ class FavoritesPage extends StatelessWidget {
|
||||
itemBuilder: (context, index) =>
|
||||
FavoriteItemTile(value.items[index]),
|
||||
)
|
||||
: Center(
|
||||
: const Center(
|
||||
child: Text('No favorites added.'),
|
||||
),
|
||||
),
|
||||
@@ -52,11 +52,11 @@ class FavoriteItemTile extends StatelessWidget {
|
||||
),
|
||||
trailing: IconButton(
|
||||
key: Key('remove_icon_$itemNo'),
|
||||
icon: Icon(Icons.close),
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: () {
|
||||
Provider.of<Favorites>(context, listen: false).remove(itemNo);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Removed from favorites.'),
|
||||
duration: Duration(seconds: 1),
|
||||
),
|
||||
|
||||
@@ -14,15 +14,15 @@ class HomePage extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Testing Sample'),
|
||||
title: const Text('Testing Sample'),
|
||||
actions: <Widget>[
|
||||
TextButton.icon(
|
||||
style: TextButton.styleFrom(primary: Colors.white),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, FavoritesPage.routeName);
|
||||
},
|
||||
icon: Icon(Icons.favorite_border),
|
||||
label: Text('Favorites'),
|
||||
icon: const Icon(Icons.favorite_border),
|
||||
label: const Text('Favorites'),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -61,8 +61,8 @@ class ItemTile extends StatelessWidget {
|
||||
trailing: IconButton(
|
||||
key: Key('icon_$itemNo'),
|
||||
icon: favoritesList.items.contains(itemNo)
|
||||
? Icon(Icons.favorite)
|
||||
: Icon(Icons.favorite_border),
|
||||
? const Icon(Icons.favorite)
|
||||
: const Icon(Icons.favorite_border),
|
||||
onPressed: () {
|
||||
!favoritesList.items.contains(itemNo)
|
||||
? favoritesList.add(itemNo)
|
||||
@@ -72,7 +72,7 @@ class ItemTile extends StatelessWidget {
|
||||
content: Text(favoritesList.items.contains(itemNo)
|
||||
? 'Added to favorites.'
|
||||
: 'Removed from favorites.'),
|
||||
duration: Duration(seconds: 1),
|
||||
duration: const Duration(seconds: 1),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user