diff --git a/MAINTENANCE.md b/MAINTENANCE.md index de9575b14..72c7bfa1c 100644 --- a/MAINTENANCE.md +++ b/MAINTENANCE.md @@ -17,6 +17,6 @@ match any new language/SDK features, etc.). | platform_design | johnpryan | 10/7/19 | | platform_view_swift | redbrogdon | 10/7/19 | | provider_counter | redbrogdon | 11/21/19 | -| provider_shopper | | | +| provider_shopper | redbrogdon | 11/21/19 | | veggieseasons | | | | web | | | diff --git a/provider_shopper/.gitignore b/provider_shopper/.gitignore index 808f1fc86..c39f0d07f 100644 --- a/provider_shopper/.gitignore +++ b/provider_shopper/.gitignore @@ -55,6 +55,7 @@ **/ios/.generated/ **/ios/Flutter/App.framework **/ios/Flutter/Flutter.framework +**/ios/Flutter/Flutter.podspec **/ios/Flutter/Generated.xcconfig **/ios/Flutter/app.flx **/ios/Flutter/app.zip diff --git a/provider_shopper/lib/main.dart b/provider_shopper/lib/main.dart index 6d025f4d2..41e357ad7 100644 --- a/provider_shopper/lib/main.dart +++ b/provider_shopper/lib/main.dart @@ -27,8 +27,10 @@ class MyApp extends StatelessWidget { // of ChangeNotifierProvider. Moreover, CartModel depends // on CatalogModel, so a ProxyProvider is needed. ChangeNotifierProxyProvider( - builder: (context, catalog, previousCart) => - CartModel(catalog, previousCart)), + initialBuilder: (context) => CartModel.empty(), + builder: (context, catalog, previousCart) => + CartModel(catalog, previousCart), + ), ], child: MaterialApp( title: 'Provider Demo', diff --git a/provider_shopper/lib/models/cart.dart b/provider_shopper/lib/models/cart.dart index 8a9274cb0..8da8ce389 100644 --- a/provider_shopper/lib/models/cart.dart +++ b/provider_shopper/lib/models/cart.dart @@ -15,12 +15,17 @@ class CartModel extends ChangeNotifier { /// Construct a CartModel instance that is backed by a [CatalogModel] and /// an optional previous state of the cart. /// - /// If [previous] is not `null`, it's items are copied to the newly + /// If [previous] is not `null`, its items are copied to the newly /// constructed instance. CartModel(this._catalog, CartModel previous) : assert(_catalog != null), _itemIds = previous?._itemIds ?? []; + /// An empty cart with no Catalog. + CartModel.empty() + : _catalog = null, + _itemIds = []; + /// List of items in the cart. List get items => _itemIds.map((id) => _catalog.getById(id)).toList(); diff --git a/provider_shopper/pubspec.lock b/provider_shopper/pubspec.lock index 3c078c538..f064fbcbc 100644 --- a/provider_shopper/pubspec.lock +++ b/provider_shopper/pubspec.lock @@ -1,20 +1,6 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - analyzer: - dependency: transitive - description: - name: analyzer - url: "https://pub.dartlang.org" - source: hosted - version: "0.36.4" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "1.5.2" async: dependency: transitive description: @@ -43,27 +29,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.14.11" - convert: - dependency: transitive - description: - name: convert - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" - crypto: - dependency: transitive - description: - name: crypto - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.3" - csslib: - dependency: transitive - description: - name: csslib - url: "https://pub.dartlang.org" - source: hosted - version: "0.16.1" flutter: dependency: "direct main" description: flutter @@ -74,76 +39,6 @@ packages: description: flutter source: sdk version: "0.0.0" - front_end: - dependency: transitive - description: - name: front_end - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.19" - glob: - dependency: transitive - description: - name: glob - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - html: - dependency: transitive - description: - name: html - url: "https://pub.dartlang.org" - source: hosted - version: "0.14.0+3" - http: - dependency: transitive - description: - name: http - url: "https://pub.dartlang.org" - source: hosted - version: "0.12.0+2" - http_multi_server: - dependency: transitive - description: - name: http_multi_server - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - http_parser: - dependency: transitive - description: - name: http_parser - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.3" - io: - dependency: transitive - description: - name: io - url: "https://pub.dartlang.org" - source: hosted - version: "0.3.3" - js: - dependency: transitive - description: - name: js - url: "https://pub.dartlang.org" - source: hosted - version: "0.6.1+1" - json_rpc_2: - dependency: transitive - description: - name: json_rpc_2 - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - kernel: - dependency: transitive - description: - name: kernel - url: "https://pub.dartlang.org" - source: hosted - version: "0.3.19" matcher: dependency: transitive description: @@ -158,55 +53,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.7" - mime: - dependency: transitive - description: - name: mime - url: "https://pub.dartlang.org" - source: hosted - version: "0.9.6+3" - multi_server_socket: - dependency: transitive - description: - name: multi_server_socket - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.2" - node_interop: - dependency: transitive - description: - name: node_interop - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.3" - node_io: - dependency: transitive - description: - name: node_io - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.1+2" - node_preamble: - dependency: transitive - description: - name: node_preamble - url: "https://pub.dartlang.org" - source: hosted - version: "1.4.8" - package_config: - dependency: transitive - description: - name: package_config - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - package_resolver: - dependency: transitive - description: - name: package_resolver - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.10" path: dependency: transitive description: @@ -221,13 +67,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0+1" - pool: - dependency: transitive - description: - name: pool - url: "https://pub.dartlang.org" - source: hosted - version: "1.4.0" provider: dependency: "direct main" description: @@ -235,13 +74,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.0+1" - pub_semver: - dependency: transitive - description: - name: pub_semver - url: "https://pub.dartlang.org" - source: hosted - version: "1.4.2" quiver: dependency: transitive description: @@ -249,53 +81,11 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.5" - shelf: - dependency: transitive - description: - name: shelf - url: "https://pub.dartlang.org" - source: hosted - version: "0.7.5" - shelf_packages_handler: - dependency: transitive - description: - name: shelf_packages_handler - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.4" - shelf_static: - dependency: transitive - description: - name: shelf_static - url: "https://pub.dartlang.org" - source: hosted - version: "0.2.8" - shelf_web_socket: - dependency: transitive - description: - name: shelf_web_socket - url: "https://pub.dartlang.org" - source: hosted - version: "0.2.3" sky_engine: dependency: transitive description: flutter source: sdk version: "0.0.99" - source_map_stack_trace: - dependency: transitive - description: - name: source_map_stack_trace - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.5" - source_maps: - dependency: transitive - description: - name: source_maps - url: "https://pub.dartlang.org" - source: hosted - version: "0.10.8" source_span: dependency: transitive description: @@ -331,13 +121,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.0" - test: - dependency: "direct dev" - description: - name: test - url: "https://pub.dartlang.org" - source: hosted - version: "1.6.3" test_api: dependency: transitive description: @@ -345,13 +128,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.2.5" - test_core: - dependency: transitive - description: - name: test_core - url: "https://pub.dartlang.org" - source: hosted - version: "0.2.5" typed_data: dependency: transitive description: @@ -366,33 +142,5 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.8" - vm_service_client: - dependency: transitive - description: - name: vm_service_client - url: "https://pub.dartlang.org" - source: hosted - version: "0.2.6+3" - watcher: - dependency: transitive - description: - name: watcher - url: "https://pub.dartlang.org" - source: hosted - version: "0.9.7+13" - web_socket_channel: - dependency: transitive - description: - name: web_socket_channel - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - yaml: - dependency: transitive - description: - name: yaml - url: "https://pub.dartlang.org" - source: hosted - version: "2.2.0" sdks: dart: ">=2.5.0 <3.0.0" diff --git a/provider_shopper/pubspec.yaml b/provider_shopper/pubspec.yaml index e41977e45..5203b33c1 100644 --- a/provider_shopper/pubspec.yaml +++ b/provider_shopper/pubspec.yaml @@ -11,13 +11,12 @@ dependencies: sdk: flutter # Import the provider package. - provider: ^3.0.0 + provider: ^3.1.0 dev_dependencies: flutter_test: sdk: flutter pedantic: ^1.8.0 - test: ^1.5.1 flutter: uses-material-design: true