1
0
mirror of https://github.com/flutter/samples.git synced 2026-03-22 04:17:50 +00:00

Landing beta changes in master for the new stable release (#747)

This commit is contained in:
Andrew Brogdon
2021-03-03 11:44:35 -08:00
committed by GitHub
parent 6c81510d6e
commit 8c1cd0b049
101 changed files with 1006 additions and 1040 deletions

View File

@@ -30,6 +30,7 @@ class MyApp extends StatelessWidget {
ChangeNotifierProxyProvider<CatalogModel, CartModel>(
create: (context) => CartModel(),
update: (context, catalog, cart) {
if (cart == null) throw ArgumentError.notNull('cart');
cart.catalog = catalog;
return cart;
},

View File

@@ -7,7 +7,7 @@ import 'package:provider_shopper/models/catalog.dart';
class CartModel extends ChangeNotifier {
/// The private field backing [catalog].
CatalogModel _catalog;
late CatalogModel _catalog;
/// Internal, private state of the cart. Stores the ids of each item.
final List<int> _itemIds = [];
@@ -16,9 +16,6 @@ class CartModel extends ChangeNotifier {
CatalogModel get catalog => _catalog;
set catalog(CatalogModel newCatalog) {
assert(newCatalog != null);
assert(_itemIds.every((id) => newCatalog.getById(id) != null),
'The catalog $newCatalog does not have one of $_itemIds in it.');
_catalog = newCatalog;
// Notify listeners, in case the new catalog provides information
// different from the previous one. For example, availability of an item

View File

@@ -65,7 +65,7 @@ class _CartTotal extends StatelessWidget {
@override
Widget build(BuildContext context) {
var hugeStyle =
Theme.of(context).textTheme.headline1.copyWith(fontSize: 48);
Theme.of(context).textTheme.headline1!.copyWith(fontSize: 48);
return SizedBox(
height: 200,
@@ -85,7 +85,7 @@ class _CartTotal extends StatelessWidget {
SizedBox(width: 24),
TextButton(
onPressed: () {
Scaffold.of(context).showSnackBar(
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Buying not supported yet.')));
},
style: TextButton.styleFrom(primary: Colors.white),

View File

@@ -28,7 +28,7 @@ class MyCatalog extends StatelessWidget {
class _AddButton extends StatelessWidget {
final Item item;
const _AddButton({Key key, @required this.item}) : super(key: key);
const _AddButton({required this.item, Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
@@ -55,7 +55,7 @@ class _AddButton extends StatelessWidget {
cart.add(item);
},
style: ButtonStyle(
overlayColor: MaterialStateProperty.resolveWith<Color>((states) {
overlayColor: MaterialStateProperty.resolveWith<Color?>((states) {
if (states.contains(MaterialState.pressed)) {
return Theme.of(context).primaryColor;
}
@@ -86,7 +86,7 @@ class _MyAppBar extends StatelessWidget {
class _MyListItem extends StatelessWidget {
final int index;
_MyListItem(this.index, {Key key}) : super(key: key);
_MyListItem(this.index, {Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {