diff --git a/cupertino_store/step_00/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/cupertino_store/step_00/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a16ed..919434a625 100644 --- a/cupertino_store/step_00/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/cupertino_store/step_00/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/cupertino_store/step_00/pubspec.lock b/cupertino_store/step_00/pubspec.lock index d12693e20e..fb2c61b5f4 100644 --- a/cupertino_store/step_00/pubspec.lock +++ b/cupertino_store/step_00/pubspec.lock @@ -7,42 +7,42 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.3" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.5" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.5" + version: "1.15.0" cupertino_icons: dependency: "direct main" description: @@ -56,7 +56,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -73,56 +73,56 @@ packages: name: intl url: "https://pub.dartlang.org" source: hosted - version: "0.16.1" + version: "0.17.0" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.3" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.6" + version: "1.3.0" nested: dependency: transitive description: name: nested url: "https://pub.dartlang.org" source: hosted - version: "0.0.4" + version: "1.0.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.3" + version: "1.8.0" pedantic: dependency: "direct dev" description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.9.2" + version: "1.10.0" provider: dependency: "direct main" description: name: provider url: "https://pub.dartlang.org" source: hosted - version: "4.3.2+4" + version: "5.0.0-nullsafety.4" shrine_images: dependency: "direct main" description: name: shrine_images url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "2.0.1" sky_engine: dependency: transitive description: flutter @@ -134,56 +134,56 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.4" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.6" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.6" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.5" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.5" + version: "2.1.0" sdks: - dart: ">=2.12.0-0.0 <3.0.0" + dart: ">=2.12.0-259.8.beta <3.0.0" flutter: ">=1.16.0" diff --git a/cupertino_store/step_00/pubspec.yaml b/cupertino_store/step_00/pubspec.yaml index b267d7b0df..6c80e2ef53 100644 --- a/cupertino_store/step_00/pubspec.yaml +++ b/cupertino_store/step_00/pubspec.yaml @@ -18,20 +18,20 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.7.0 <3.0.0" + sdk: ">=2.12.0-259.8.beta <3.0.0" dependencies: - cupertino_icons: ^1.0.0 + cupertino_icons: ^1.0.2 flutter: sdk: flutter - intl: ^0.16.1 - provider: ^4.1.1 - shrine_images: ^1.0.0 + intl: ^0.17.0 + provider: ^5.0.0-0 + shrine_images: ^2.0.1 dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.9.0 + pedantic: ^1.10.0 flutter: assets: diff --git a/cupertino_store/step_01/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/cupertino_store/step_01/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a16ed..919434a625 100644 --- a/cupertino_store/step_01/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/cupertino_store/step_01/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/cupertino_store/step_01/lib/app.dart b/cupertino_store/step_01/lib/app.dart index ad335f7810..993f086973 100644 --- a/cupertino_store/step_01/lib/app.dart +++ b/cupertino_store/step_01/lib/app.dart @@ -54,7 +54,7 @@ class CupertinoStoreHomePage extends StatelessWidget { ], ), tabBuilder: (context, index) { - CupertinoTabView returnValue; + late final CupertinoTabView returnValue; switch (index) { case 0: returnValue = CupertinoTabView(builder: (context) { diff --git a/cupertino_store/step_01/lib/model/app_state_model.dart b/cupertino_store/step_01/lib/model/app_state_model.dart index b419f96d03..e35429dcaf 100644 --- a/cupertino_store/step_01/lib/model/app_state_model.dart +++ b/cupertino_store/step_01/lib/model/app_state_model.dart @@ -22,7 +22,7 @@ double _shippingCostPerItem = 7; class AppStateModel extends foundation.ChangeNotifier { // All the available products. - List _availableProducts; + List _availableProducts = []; // The currently selected category of products. Category _selectedCategory = Category.all; @@ -49,7 +49,7 @@ class AppStateModel extends foundation.ChangeNotifier { double get subtotalCost { return _productsInCart.keys.map((id) { // Extended price for product line - return getProductById(id).price * _productsInCart[id]; + return getProductById(id).price * _productsInCart[id]!; }).fold(0, (accumulator, extendedPrice) { return accumulator + extendedPrice; }); @@ -75,10 +75,6 @@ class AppStateModel extends foundation.ChangeNotifier { // Returns a copy of the list of available products, filtered by category. List getProducts() { - if (_availableProducts == null) { - return []; - } - if (_selectedCategory == Category.all) { return List.from(_availableProducts); } else { @@ -100,7 +96,7 @@ class AppStateModel extends foundation.ChangeNotifier { if (!_productsInCart.containsKey(productId)) { _productsInCart[productId] = 1; } else { - _productsInCart[productId]++; + _productsInCart[productId] = _productsInCart[productId]! + 1; } notifyListeners(); @@ -112,7 +108,7 @@ class AppStateModel extends foundation.ChangeNotifier { if (_productsInCart[productId] == 1) { _productsInCart.remove(productId); } else { - _productsInCart[productId]--; + _productsInCart[productId] = _productsInCart[productId]! - 1; } } diff --git a/cupertino_store/step_01/lib/model/product.dart b/cupertino_store/step_01/lib/model/product.dart index 159691fe09..a0a5837188 100644 --- a/cupertino_store/step_01/lib/model/product.dart +++ b/cupertino_store/step_01/lib/model/product.dart @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import 'package:flutter/foundation.dart'; - enum Category { all, accessories, @@ -23,16 +21,12 @@ enum Category { class Product { const Product({ - @required this.category, - @required this.id, - @required this.isFeatured, - @required this.name, - @required this.price, - }) : assert(category != null, 'category must not be null'), - assert(id != null, 'id must not be null'), - assert(isFeatured != null, 'isFeatured must not be null'), - assert(name != null, 'name must not be null'), - assert(price != null, 'price must not be null'); + required this.category, + required this.id, + required this.isFeatured, + required this.name, + required this.price, + }); final Category category; final int id; diff --git a/cupertino_store/step_01/pubspec.lock b/cupertino_store/step_01/pubspec.lock index d12693e20e..fb2c61b5f4 100644 --- a/cupertino_store/step_01/pubspec.lock +++ b/cupertino_store/step_01/pubspec.lock @@ -7,42 +7,42 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.3" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.5" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.5" + version: "1.15.0" cupertino_icons: dependency: "direct main" description: @@ -56,7 +56,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -73,56 +73,56 @@ packages: name: intl url: "https://pub.dartlang.org" source: hosted - version: "0.16.1" + version: "0.17.0" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.3" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.6" + version: "1.3.0" nested: dependency: transitive description: name: nested url: "https://pub.dartlang.org" source: hosted - version: "0.0.4" + version: "1.0.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.3" + version: "1.8.0" pedantic: dependency: "direct dev" description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.9.2" + version: "1.10.0" provider: dependency: "direct main" description: name: provider url: "https://pub.dartlang.org" source: hosted - version: "4.3.2+4" + version: "5.0.0-nullsafety.4" shrine_images: dependency: "direct main" description: name: shrine_images url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "2.0.1" sky_engine: dependency: transitive description: flutter @@ -134,56 +134,56 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.4" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.6" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.6" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.5" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.5" + version: "2.1.0" sdks: - dart: ">=2.12.0-0.0 <3.0.0" + dart: ">=2.12.0-259.8.beta <3.0.0" flutter: ">=1.16.0" diff --git a/cupertino_store/step_01/pubspec.yaml b/cupertino_store/step_01/pubspec.yaml index b267d7b0df..6c80e2ef53 100644 --- a/cupertino_store/step_01/pubspec.yaml +++ b/cupertino_store/step_01/pubspec.yaml @@ -18,20 +18,20 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.7.0 <3.0.0" + sdk: ">=2.12.0-259.8.beta <3.0.0" dependencies: - cupertino_icons: ^1.0.0 + cupertino_icons: ^1.0.2 flutter: sdk: flutter - intl: ^0.16.1 - provider: ^4.1.1 - shrine_images: ^1.0.0 + intl: ^0.17.0 + provider: ^5.0.0-0 + shrine_images: ^2.0.1 dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.9.0 + pedantic: ^1.10.0 flutter: assets: diff --git a/cupertino_store/step_02/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/cupertino_store/step_02/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a16ed..919434a625 100644 --- a/cupertino_store/step_02/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/cupertino_store/step_02/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/cupertino_store/step_02/lib/app.dart b/cupertino_store/step_02/lib/app.dart index ad335f7810..993f086973 100644 --- a/cupertino_store/step_02/lib/app.dart +++ b/cupertino_store/step_02/lib/app.dart @@ -54,7 +54,7 @@ class CupertinoStoreHomePage extends StatelessWidget { ], ), tabBuilder: (context, index) { - CupertinoTabView returnValue; + late final CupertinoTabView returnValue; switch (index) { case 0: returnValue = CupertinoTabView(builder: (context) { diff --git a/cupertino_store/step_02/lib/model/app_state_model.dart b/cupertino_store/step_02/lib/model/app_state_model.dart index b419f96d03..e35429dcaf 100644 --- a/cupertino_store/step_02/lib/model/app_state_model.dart +++ b/cupertino_store/step_02/lib/model/app_state_model.dart @@ -22,7 +22,7 @@ double _shippingCostPerItem = 7; class AppStateModel extends foundation.ChangeNotifier { // All the available products. - List _availableProducts; + List _availableProducts = []; // The currently selected category of products. Category _selectedCategory = Category.all; @@ -49,7 +49,7 @@ class AppStateModel extends foundation.ChangeNotifier { double get subtotalCost { return _productsInCart.keys.map((id) { // Extended price for product line - return getProductById(id).price * _productsInCart[id]; + return getProductById(id).price * _productsInCart[id]!; }).fold(0, (accumulator, extendedPrice) { return accumulator + extendedPrice; }); @@ -75,10 +75,6 @@ class AppStateModel extends foundation.ChangeNotifier { // Returns a copy of the list of available products, filtered by category. List getProducts() { - if (_availableProducts == null) { - return []; - } - if (_selectedCategory == Category.all) { return List.from(_availableProducts); } else { @@ -100,7 +96,7 @@ class AppStateModel extends foundation.ChangeNotifier { if (!_productsInCart.containsKey(productId)) { _productsInCart[productId] = 1; } else { - _productsInCart[productId]++; + _productsInCart[productId] = _productsInCart[productId]! + 1; } notifyListeners(); @@ -112,7 +108,7 @@ class AppStateModel extends foundation.ChangeNotifier { if (_productsInCart[productId] == 1) { _productsInCart.remove(productId); } else { - _productsInCart[productId]--; + _productsInCart[productId] = _productsInCart[productId]! - 1; } } diff --git a/cupertino_store/step_02/lib/model/product.dart b/cupertino_store/step_02/lib/model/product.dart index 159691fe09..a0a5837188 100644 --- a/cupertino_store/step_02/lib/model/product.dart +++ b/cupertino_store/step_02/lib/model/product.dart @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import 'package:flutter/foundation.dart'; - enum Category { all, accessories, @@ -23,16 +21,12 @@ enum Category { class Product { const Product({ - @required this.category, - @required this.id, - @required this.isFeatured, - @required this.name, - @required this.price, - }) : assert(category != null, 'category must not be null'), - assert(id != null, 'id must not be null'), - assert(isFeatured != null, 'isFeatured must not be null'), - assert(name != null, 'name must not be null'), - assert(price != null, 'price must not be null'); + required this.category, + required this.id, + required this.isFeatured, + required this.name, + required this.price, + }); final Category category; final int id; diff --git a/cupertino_store/step_02/lib/product_list_tab.dart b/cupertino_store/step_02/lib/product_list_tab.dart index 595729f046..53ef43568f 100644 --- a/cupertino_store/step_02/lib/product_list_tab.dart +++ b/cupertino_store/step_02/lib/product_list_tab.dart @@ -38,7 +38,6 @@ class ProductListTab extends StatelessWidget { (context, index) { if (index < products.length) { return ProductRowItem( - index: index, product: products[index], lastItem: index == products.length - 1, ); diff --git a/cupertino_store/step_02/lib/product_row_item.dart b/cupertino_store/step_02/lib/product_row_item.dart index 95930d1c38..36ff60f2d9 100644 --- a/cupertino_store/step_02/lib/product_row_item.dart +++ b/cupertino_store/step_02/lib/product_row_item.dart @@ -21,13 +21,11 @@ import 'styles.dart'; class ProductRowItem extends StatelessWidget { const ProductRowItem({ - this.index, - this.product, - this.lastItem, + required this.product, + required this.lastItem, }); final Product product; - final int index; final bool lastItem; @override diff --git a/cupertino_store/step_02/pubspec.lock b/cupertino_store/step_02/pubspec.lock index d12693e20e..fb2c61b5f4 100644 --- a/cupertino_store/step_02/pubspec.lock +++ b/cupertino_store/step_02/pubspec.lock @@ -7,42 +7,42 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.3" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.5" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.5" + version: "1.15.0" cupertino_icons: dependency: "direct main" description: @@ -56,7 +56,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -73,56 +73,56 @@ packages: name: intl url: "https://pub.dartlang.org" source: hosted - version: "0.16.1" + version: "0.17.0" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.3" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.6" + version: "1.3.0" nested: dependency: transitive description: name: nested url: "https://pub.dartlang.org" source: hosted - version: "0.0.4" + version: "1.0.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.3" + version: "1.8.0" pedantic: dependency: "direct dev" description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.9.2" + version: "1.10.0" provider: dependency: "direct main" description: name: provider url: "https://pub.dartlang.org" source: hosted - version: "4.3.2+4" + version: "5.0.0-nullsafety.4" shrine_images: dependency: "direct main" description: name: shrine_images url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "2.0.1" sky_engine: dependency: transitive description: flutter @@ -134,56 +134,56 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.4" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.6" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.6" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.5" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.5" + version: "2.1.0" sdks: - dart: ">=2.12.0-0.0 <3.0.0" + dart: ">=2.12.0-259.8.beta <3.0.0" flutter: ">=1.16.0" diff --git a/cupertino_store/step_02/pubspec.yaml b/cupertino_store/step_02/pubspec.yaml index b267d7b0df..6c80e2ef53 100644 --- a/cupertino_store/step_02/pubspec.yaml +++ b/cupertino_store/step_02/pubspec.yaml @@ -18,20 +18,20 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.7.0 <3.0.0" + sdk: ">=2.12.0-259.8.beta <3.0.0" dependencies: - cupertino_icons: ^1.0.0 + cupertino_icons: ^1.0.2 flutter: sdk: flutter - intl: ^0.16.1 - provider: ^4.1.1 - shrine_images: ^1.0.0 + intl: ^0.17.0 + provider: ^5.0.0-0 + shrine_images: ^2.0.1 dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.9.0 + pedantic: ^1.10.0 flutter: assets: diff --git a/cupertino_store/step_03/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/cupertino_store/step_03/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a16ed..919434a625 100644 --- a/cupertino_store/step_03/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/cupertino_store/step_03/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/cupertino_store/step_03/lib/app.dart b/cupertino_store/step_03/lib/app.dart index ad335f7810..993f086973 100644 --- a/cupertino_store/step_03/lib/app.dart +++ b/cupertino_store/step_03/lib/app.dart @@ -54,7 +54,7 @@ class CupertinoStoreHomePage extends StatelessWidget { ], ), tabBuilder: (context, index) { - CupertinoTabView returnValue; + late final CupertinoTabView returnValue; switch (index) { case 0: returnValue = CupertinoTabView(builder: (context) { diff --git a/cupertino_store/step_03/lib/model/app_state_model.dart b/cupertino_store/step_03/lib/model/app_state_model.dart index b419f96d03..e35429dcaf 100644 --- a/cupertino_store/step_03/lib/model/app_state_model.dart +++ b/cupertino_store/step_03/lib/model/app_state_model.dart @@ -22,7 +22,7 @@ double _shippingCostPerItem = 7; class AppStateModel extends foundation.ChangeNotifier { // All the available products. - List _availableProducts; + List _availableProducts = []; // The currently selected category of products. Category _selectedCategory = Category.all; @@ -49,7 +49,7 @@ class AppStateModel extends foundation.ChangeNotifier { double get subtotalCost { return _productsInCart.keys.map((id) { // Extended price for product line - return getProductById(id).price * _productsInCart[id]; + return getProductById(id).price * _productsInCart[id]!; }).fold(0, (accumulator, extendedPrice) { return accumulator + extendedPrice; }); @@ -75,10 +75,6 @@ class AppStateModel extends foundation.ChangeNotifier { // Returns a copy of the list of available products, filtered by category. List getProducts() { - if (_availableProducts == null) { - return []; - } - if (_selectedCategory == Category.all) { return List.from(_availableProducts); } else { @@ -100,7 +96,7 @@ class AppStateModel extends foundation.ChangeNotifier { if (!_productsInCart.containsKey(productId)) { _productsInCart[productId] = 1; } else { - _productsInCart[productId]++; + _productsInCart[productId] = _productsInCart[productId]! + 1; } notifyListeners(); @@ -112,7 +108,7 @@ class AppStateModel extends foundation.ChangeNotifier { if (_productsInCart[productId] == 1) { _productsInCart.remove(productId); } else { - _productsInCart[productId]--; + _productsInCart[productId] = _productsInCart[productId]! - 1; } } diff --git a/cupertino_store/step_03/lib/model/product.dart b/cupertino_store/step_03/lib/model/product.dart index 159691fe09..a0a5837188 100644 --- a/cupertino_store/step_03/lib/model/product.dart +++ b/cupertino_store/step_03/lib/model/product.dart @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import 'package:flutter/foundation.dart'; - enum Category { all, accessories, @@ -23,16 +21,12 @@ enum Category { class Product { const Product({ - @required this.category, - @required this.id, - @required this.isFeatured, - @required this.name, - @required this.price, - }) : assert(category != null, 'category must not be null'), - assert(id != null, 'id must not be null'), - assert(isFeatured != null, 'isFeatured must not be null'), - assert(name != null, 'name must not be null'), - assert(price != null, 'price must not be null'); + required this.category, + required this.id, + required this.isFeatured, + required this.name, + required this.price, + }); final Category category; final int id; diff --git a/cupertino_store/step_03/lib/product_list_tab.dart b/cupertino_store/step_03/lib/product_list_tab.dart index 595729f046..53ef43568f 100644 --- a/cupertino_store/step_03/lib/product_list_tab.dart +++ b/cupertino_store/step_03/lib/product_list_tab.dart @@ -38,7 +38,6 @@ class ProductListTab extends StatelessWidget { (context, index) { if (index < products.length) { return ProductRowItem( - index: index, product: products[index], lastItem: index == products.length - 1, ); diff --git a/cupertino_store/step_03/lib/product_row_item.dart b/cupertino_store/step_03/lib/product_row_item.dart index 95930d1c38..36ff60f2d9 100644 --- a/cupertino_store/step_03/lib/product_row_item.dart +++ b/cupertino_store/step_03/lib/product_row_item.dart @@ -21,13 +21,11 @@ import 'styles.dart'; class ProductRowItem extends StatelessWidget { const ProductRowItem({ - this.index, - this.product, - this.lastItem, + required this.product, + required this.lastItem, }); final Product product; - final int index; final bool lastItem; @override diff --git a/cupertino_store/step_03/lib/search_bar.dart b/cupertino_store/step_03/lib/search_bar.dart index 4f992f2f67..758bbeca7f 100644 --- a/cupertino_store/step_03/lib/search_bar.dart +++ b/cupertino_store/step_03/lib/search_bar.dart @@ -8,8 +8,8 @@ import 'styles.dart'; class SearchBar extends StatelessWidget { const SearchBar({ - @required this.controller, - @required this.focusNode, + required this.controller, + required this.focusNode, }); final TextEditingController controller; diff --git a/cupertino_store/step_03/lib/search_tab.dart b/cupertino_store/step_03/lib/search_tab.dart index 370f9a3b05..9513351bc7 100644 --- a/cupertino_store/step_03/lib/search_tab.dart +++ b/cupertino_store/step_03/lib/search_tab.dart @@ -28,8 +28,8 @@ class SearchTab extends StatefulWidget { } class _SearchTabState extends State { - TextEditingController _controller; - FocusNode _focusNode; + late final TextEditingController _controller; + late final FocusNode _focusNode; String _terms = ''; @override @@ -78,7 +78,6 @@ class _SearchTabState extends State { Expanded( child: ListView.builder( itemBuilder: (context, index) => ProductRowItem( - index: index, product: results[index], lastItem: index == results.length - 1, ), diff --git a/cupertino_store/step_03/pubspec.lock b/cupertino_store/step_03/pubspec.lock index d12693e20e..fb2c61b5f4 100644 --- a/cupertino_store/step_03/pubspec.lock +++ b/cupertino_store/step_03/pubspec.lock @@ -7,42 +7,42 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.3" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.5" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.5" + version: "1.15.0" cupertino_icons: dependency: "direct main" description: @@ -56,7 +56,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -73,56 +73,56 @@ packages: name: intl url: "https://pub.dartlang.org" source: hosted - version: "0.16.1" + version: "0.17.0" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.3" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.6" + version: "1.3.0" nested: dependency: transitive description: name: nested url: "https://pub.dartlang.org" source: hosted - version: "0.0.4" + version: "1.0.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.3" + version: "1.8.0" pedantic: dependency: "direct dev" description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.9.2" + version: "1.10.0" provider: dependency: "direct main" description: name: provider url: "https://pub.dartlang.org" source: hosted - version: "4.3.2+4" + version: "5.0.0-nullsafety.4" shrine_images: dependency: "direct main" description: name: shrine_images url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "2.0.1" sky_engine: dependency: transitive description: flutter @@ -134,56 +134,56 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.4" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.6" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.6" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.5" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.5" + version: "2.1.0" sdks: - dart: ">=2.12.0-0.0 <3.0.0" + dart: ">=2.12.0-259.8.beta <3.0.0" flutter: ">=1.16.0" diff --git a/cupertino_store/step_03/pubspec.yaml b/cupertino_store/step_03/pubspec.yaml index b267d7b0df..6c80e2ef53 100644 --- a/cupertino_store/step_03/pubspec.yaml +++ b/cupertino_store/step_03/pubspec.yaml @@ -18,20 +18,20 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.7.0 <3.0.0" + sdk: ">=2.12.0-259.8.beta <3.0.0" dependencies: - cupertino_icons: ^1.0.0 + cupertino_icons: ^1.0.2 flutter: sdk: flutter - intl: ^0.16.1 - provider: ^4.1.1 - shrine_images: ^1.0.0 + intl: ^0.17.0 + provider: ^5.0.0-0 + shrine_images: ^2.0.1 dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.9.0 + pedantic: ^1.10.0 flutter: assets: diff --git a/cupertino_store/step_04/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/cupertino_store/step_04/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a16ed..919434a625 100644 --- a/cupertino_store/step_04/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/cupertino_store/step_04/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/cupertino_store/step_04/lib/app.dart b/cupertino_store/step_04/lib/app.dart index ad335f7810..993f086973 100644 --- a/cupertino_store/step_04/lib/app.dart +++ b/cupertino_store/step_04/lib/app.dart @@ -54,7 +54,7 @@ class CupertinoStoreHomePage extends StatelessWidget { ], ), tabBuilder: (context, index) { - CupertinoTabView returnValue; + late final CupertinoTabView returnValue; switch (index) { case 0: returnValue = CupertinoTabView(builder: (context) { diff --git a/cupertino_store/step_04/lib/model/app_state_model.dart b/cupertino_store/step_04/lib/model/app_state_model.dart index b419f96d03..e35429dcaf 100644 --- a/cupertino_store/step_04/lib/model/app_state_model.dart +++ b/cupertino_store/step_04/lib/model/app_state_model.dart @@ -22,7 +22,7 @@ double _shippingCostPerItem = 7; class AppStateModel extends foundation.ChangeNotifier { // All the available products. - List _availableProducts; + List _availableProducts = []; // The currently selected category of products. Category _selectedCategory = Category.all; @@ -49,7 +49,7 @@ class AppStateModel extends foundation.ChangeNotifier { double get subtotalCost { return _productsInCart.keys.map((id) { // Extended price for product line - return getProductById(id).price * _productsInCart[id]; + return getProductById(id).price * _productsInCart[id]!; }).fold(0, (accumulator, extendedPrice) { return accumulator + extendedPrice; }); @@ -75,10 +75,6 @@ class AppStateModel extends foundation.ChangeNotifier { // Returns a copy of the list of available products, filtered by category. List getProducts() { - if (_availableProducts == null) { - return []; - } - if (_selectedCategory == Category.all) { return List.from(_availableProducts); } else { @@ -100,7 +96,7 @@ class AppStateModel extends foundation.ChangeNotifier { if (!_productsInCart.containsKey(productId)) { _productsInCart[productId] = 1; } else { - _productsInCart[productId]++; + _productsInCart[productId] = _productsInCart[productId]! + 1; } notifyListeners(); @@ -112,7 +108,7 @@ class AppStateModel extends foundation.ChangeNotifier { if (_productsInCart[productId] == 1) { _productsInCart.remove(productId); } else { - _productsInCart[productId]--; + _productsInCart[productId] = _productsInCart[productId]! - 1; } } diff --git a/cupertino_store/step_04/lib/model/product.dart b/cupertino_store/step_04/lib/model/product.dart index 159691fe09..a0a5837188 100644 --- a/cupertino_store/step_04/lib/model/product.dart +++ b/cupertino_store/step_04/lib/model/product.dart @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import 'package:flutter/foundation.dart'; - enum Category { all, accessories, @@ -23,16 +21,12 @@ enum Category { class Product { const Product({ - @required this.category, - @required this.id, - @required this.isFeatured, - @required this.name, - @required this.price, - }) : assert(category != null, 'category must not be null'), - assert(id != null, 'id must not be null'), - assert(isFeatured != null, 'isFeatured must not be null'), - assert(name != null, 'name must not be null'), - assert(price != null, 'price must not be null'); + required this.category, + required this.id, + required this.isFeatured, + required this.name, + required this.price, + }); final Category category; final int id; diff --git a/cupertino_store/step_04/lib/product_list_tab.dart b/cupertino_store/step_04/lib/product_list_tab.dart index 595729f046..53ef43568f 100644 --- a/cupertino_store/step_04/lib/product_list_tab.dart +++ b/cupertino_store/step_04/lib/product_list_tab.dart @@ -38,7 +38,6 @@ class ProductListTab extends StatelessWidget { (context, index) { if (index < products.length) { return ProductRowItem( - index: index, product: products[index], lastItem: index == products.length - 1, ); diff --git a/cupertino_store/step_04/lib/product_row_item.dart b/cupertino_store/step_04/lib/product_row_item.dart index 95930d1c38..36ff60f2d9 100644 --- a/cupertino_store/step_04/lib/product_row_item.dart +++ b/cupertino_store/step_04/lib/product_row_item.dart @@ -21,13 +21,11 @@ import 'styles.dart'; class ProductRowItem extends StatelessWidget { const ProductRowItem({ - this.index, - this.product, - this.lastItem, + required this.product, + required this.lastItem, }); final Product product; - final int index; final bool lastItem; @override diff --git a/cupertino_store/step_04/lib/search_bar.dart b/cupertino_store/step_04/lib/search_bar.dart index 4f992f2f67..758bbeca7f 100644 --- a/cupertino_store/step_04/lib/search_bar.dart +++ b/cupertino_store/step_04/lib/search_bar.dart @@ -8,8 +8,8 @@ import 'styles.dart'; class SearchBar extends StatelessWidget { const SearchBar({ - @required this.controller, - @required this.focusNode, + required this.controller, + required this.focusNode, }); final TextEditingController controller; diff --git a/cupertino_store/step_04/lib/search_tab.dart b/cupertino_store/step_04/lib/search_tab.dart index 370f9a3b05..9513351bc7 100644 --- a/cupertino_store/step_04/lib/search_tab.dart +++ b/cupertino_store/step_04/lib/search_tab.dart @@ -28,8 +28,8 @@ class SearchTab extends StatefulWidget { } class _SearchTabState extends State { - TextEditingController _controller; - FocusNode _focusNode; + late final TextEditingController _controller; + late final FocusNode _focusNode; String _terms = ''; @override @@ -78,7 +78,6 @@ class _SearchTabState extends State { Expanded( child: ListView.builder( itemBuilder: (context, index) => ProductRowItem( - index: index, product: results[index], lastItem: index == results.length - 1, ), diff --git a/cupertino_store/step_04/lib/shopping_cart_tab.dart b/cupertino_store/step_04/lib/shopping_cart_tab.dart index 1f15640322..3b41339a7e 100644 --- a/cupertino_store/step_04/lib/shopping_cart_tab.dart +++ b/cupertino_store/step_04/lib/shopping_cart_tab.dart @@ -25,10 +25,10 @@ class ShoppingCartTab extends StatefulWidget { } class _ShoppingCartTabState extends State { - String name; - String email; - String location; - String pin; + String? name; + String? email; + String? location; + String? pin; DateTime dateTime = DateTime.now(); Widget _buildNameField() { diff --git a/cupertino_store/step_04/pubspec.lock b/cupertino_store/step_04/pubspec.lock index d12693e20e..fb2c61b5f4 100644 --- a/cupertino_store/step_04/pubspec.lock +++ b/cupertino_store/step_04/pubspec.lock @@ -7,42 +7,42 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.3" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.5" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.5" + version: "1.15.0" cupertino_icons: dependency: "direct main" description: @@ -56,7 +56,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -73,56 +73,56 @@ packages: name: intl url: "https://pub.dartlang.org" source: hosted - version: "0.16.1" + version: "0.17.0" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.3" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.6" + version: "1.3.0" nested: dependency: transitive description: name: nested url: "https://pub.dartlang.org" source: hosted - version: "0.0.4" + version: "1.0.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.3" + version: "1.8.0" pedantic: dependency: "direct dev" description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.9.2" + version: "1.10.0" provider: dependency: "direct main" description: name: provider url: "https://pub.dartlang.org" source: hosted - version: "4.3.2+4" + version: "5.0.0-nullsafety.4" shrine_images: dependency: "direct main" description: name: shrine_images url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "2.0.1" sky_engine: dependency: transitive description: flutter @@ -134,56 +134,56 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.4" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.6" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.6" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.5" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.5" + version: "2.1.0" sdks: - dart: ">=2.12.0-0.0 <3.0.0" + dart: ">=2.12.0-259.8.beta <3.0.0" flutter: ">=1.16.0" diff --git a/cupertino_store/step_04/pubspec.yaml b/cupertino_store/step_04/pubspec.yaml index b267d7b0df..6c80e2ef53 100644 --- a/cupertino_store/step_04/pubspec.yaml +++ b/cupertino_store/step_04/pubspec.yaml @@ -18,20 +18,20 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.7.0 <3.0.0" + sdk: ">=2.12.0-259.8.beta <3.0.0" dependencies: - cupertino_icons: ^1.0.0 + cupertino_icons: ^1.0.2 flutter: sdk: flutter - intl: ^0.16.1 - provider: ^4.1.1 - shrine_images: ^1.0.0 + intl: ^0.17.0 + provider: ^5.0.0-0 + shrine_images: ^2.0.1 dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.9.0 + pedantic: ^1.10.0 flutter: assets: diff --git a/cupertino_store/step_05/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/cupertino_store/step_05/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a16ed..919434a625 100644 --- a/cupertino_store/step_05/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/cupertino_store/step_05/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/cupertino_store/step_05/lib/app.dart b/cupertino_store/step_05/lib/app.dart index ad335f7810..993f086973 100644 --- a/cupertino_store/step_05/lib/app.dart +++ b/cupertino_store/step_05/lib/app.dart @@ -54,7 +54,7 @@ class CupertinoStoreHomePage extends StatelessWidget { ], ), tabBuilder: (context, index) { - CupertinoTabView returnValue; + late final CupertinoTabView returnValue; switch (index) { case 0: returnValue = CupertinoTabView(builder: (context) { diff --git a/cupertino_store/step_05/lib/model/app_state_model.dart b/cupertino_store/step_05/lib/model/app_state_model.dart index b419f96d03..e35429dcaf 100644 --- a/cupertino_store/step_05/lib/model/app_state_model.dart +++ b/cupertino_store/step_05/lib/model/app_state_model.dart @@ -22,7 +22,7 @@ double _shippingCostPerItem = 7; class AppStateModel extends foundation.ChangeNotifier { // All the available products. - List _availableProducts; + List _availableProducts = []; // The currently selected category of products. Category _selectedCategory = Category.all; @@ -49,7 +49,7 @@ class AppStateModel extends foundation.ChangeNotifier { double get subtotalCost { return _productsInCart.keys.map((id) { // Extended price for product line - return getProductById(id).price * _productsInCart[id]; + return getProductById(id).price * _productsInCart[id]!; }).fold(0, (accumulator, extendedPrice) { return accumulator + extendedPrice; }); @@ -75,10 +75,6 @@ class AppStateModel extends foundation.ChangeNotifier { // Returns a copy of the list of available products, filtered by category. List getProducts() { - if (_availableProducts == null) { - return []; - } - if (_selectedCategory == Category.all) { return List.from(_availableProducts); } else { @@ -100,7 +96,7 @@ class AppStateModel extends foundation.ChangeNotifier { if (!_productsInCart.containsKey(productId)) { _productsInCart[productId] = 1; } else { - _productsInCart[productId]++; + _productsInCart[productId] = _productsInCart[productId]! + 1; } notifyListeners(); @@ -112,7 +108,7 @@ class AppStateModel extends foundation.ChangeNotifier { if (_productsInCart[productId] == 1) { _productsInCart.remove(productId); } else { - _productsInCart[productId]--; + _productsInCart[productId] = _productsInCart[productId]! - 1; } } diff --git a/cupertino_store/step_05/lib/model/product.dart b/cupertino_store/step_05/lib/model/product.dart index 159691fe09..a0a5837188 100644 --- a/cupertino_store/step_05/lib/model/product.dart +++ b/cupertino_store/step_05/lib/model/product.dart @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import 'package:flutter/foundation.dart'; - enum Category { all, accessories, @@ -23,16 +21,12 @@ enum Category { class Product { const Product({ - @required this.category, - @required this.id, - @required this.isFeatured, - @required this.name, - @required this.price, - }) : assert(category != null, 'category must not be null'), - assert(id != null, 'id must not be null'), - assert(isFeatured != null, 'isFeatured must not be null'), - assert(name != null, 'name must not be null'), - assert(price != null, 'price must not be null'); + required this.category, + required this.id, + required this.isFeatured, + required this.name, + required this.price, + }); final Category category; final int id; diff --git a/cupertino_store/step_05/lib/product_list_tab.dart b/cupertino_store/step_05/lib/product_list_tab.dart index 595729f046..53ef43568f 100644 --- a/cupertino_store/step_05/lib/product_list_tab.dart +++ b/cupertino_store/step_05/lib/product_list_tab.dart @@ -38,7 +38,6 @@ class ProductListTab extends StatelessWidget { (context, index) { if (index < products.length) { return ProductRowItem( - index: index, product: products[index], lastItem: index == products.length - 1, ); diff --git a/cupertino_store/step_05/lib/product_row_item.dart b/cupertino_store/step_05/lib/product_row_item.dart index 95930d1c38..36ff60f2d9 100644 --- a/cupertino_store/step_05/lib/product_row_item.dart +++ b/cupertino_store/step_05/lib/product_row_item.dart @@ -21,13 +21,11 @@ import 'styles.dart'; class ProductRowItem extends StatelessWidget { const ProductRowItem({ - this.index, - this.product, - this.lastItem, + required this.product, + required this.lastItem, }); final Product product; - final int index; final bool lastItem; @override diff --git a/cupertino_store/step_05/lib/search_bar.dart b/cupertino_store/step_05/lib/search_bar.dart index 4f992f2f67..758bbeca7f 100644 --- a/cupertino_store/step_05/lib/search_bar.dart +++ b/cupertino_store/step_05/lib/search_bar.dart @@ -8,8 +8,8 @@ import 'styles.dart'; class SearchBar extends StatelessWidget { const SearchBar({ - @required this.controller, - @required this.focusNode, + required this.controller, + required this.focusNode, }); final TextEditingController controller; diff --git a/cupertino_store/step_05/lib/search_tab.dart b/cupertino_store/step_05/lib/search_tab.dart index 370f9a3b05..9513351bc7 100644 --- a/cupertino_store/step_05/lib/search_tab.dart +++ b/cupertino_store/step_05/lib/search_tab.dart @@ -28,8 +28,8 @@ class SearchTab extends StatefulWidget { } class _SearchTabState extends State { - TextEditingController _controller; - FocusNode _focusNode; + late final TextEditingController _controller; + late final FocusNode _focusNode; String _terms = ''; @override @@ -78,7 +78,6 @@ class _SearchTabState extends State { Expanded( child: ListView.builder( itemBuilder: (context, index) => ProductRowItem( - index: index, product: results[index], lastItem: index == results.length - 1, ), diff --git a/cupertino_store/step_05/lib/shopping_cart_tab.dart b/cupertino_store/step_05/lib/shopping_cart_tab.dart index 4460f5de92..63eeb1751f 100644 --- a/cupertino_store/step_05/lib/shopping_cart_tab.dart +++ b/cupertino_store/step_05/lib/shopping_cart_tab.dart @@ -29,10 +29,10 @@ class ShoppingCartTab extends StatefulWidget { } class _ShoppingCartTabState extends State { - String name; - String email; - String location; - String pin; + String? name; + String? email; + String? location; + String? pin; DateTime dateTime = DateTime.now(); Widget _buildNameField() { diff --git a/cupertino_store/step_05/pubspec.lock b/cupertino_store/step_05/pubspec.lock index d12693e20e..fb2c61b5f4 100644 --- a/cupertino_store/step_05/pubspec.lock +++ b/cupertino_store/step_05/pubspec.lock @@ -7,42 +7,42 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.3" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.5" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.5" + version: "1.15.0" cupertino_icons: dependency: "direct main" description: @@ -56,7 +56,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -73,56 +73,56 @@ packages: name: intl url: "https://pub.dartlang.org" source: hosted - version: "0.16.1" + version: "0.17.0" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.3" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.6" + version: "1.3.0" nested: dependency: transitive description: name: nested url: "https://pub.dartlang.org" source: hosted - version: "0.0.4" + version: "1.0.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.3" + version: "1.8.0" pedantic: dependency: "direct dev" description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.9.2" + version: "1.10.0" provider: dependency: "direct main" description: name: provider url: "https://pub.dartlang.org" source: hosted - version: "4.3.2+4" + version: "5.0.0-nullsafety.4" shrine_images: dependency: "direct main" description: name: shrine_images url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "2.0.1" sky_engine: dependency: transitive description: flutter @@ -134,56 +134,56 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.4" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.6" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.6" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.5" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.5" + version: "2.1.0" sdks: - dart: ">=2.12.0-0.0 <3.0.0" + dart: ">=2.12.0-259.8.beta <3.0.0" flutter: ">=1.16.0" diff --git a/cupertino_store/step_05/pubspec.yaml b/cupertino_store/step_05/pubspec.yaml index b267d7b0df..6c80e2ef53 100644 --- a/cupertino_store/step_05/pubspec.yaml +++ b/cupertino_store/step_05/pubspec.yaml @@ -18,20 +18,20 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.7.0 <3.0.0" + sdk: ">=2.12.0-259.8.beta <3.0.0" dependencies: - cupertino_icons: ^1.0.0 + cupertino_icons: ^1.0.2 flutter: sdk: flutter - intl: ^0.16.1 - provider: ^4.1.1 - shrine_images: ^1.0.0 + intl: ^0.17.0 + provider: ^5.0.0-0 + shrine_images: ^2.0.1 dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.9.0 + pedantic: ^1.10.0 flutter: assets: diff --git a/cupertino_store/step_06/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/cupertino_store/step_06/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a16ed..919434a625 100644 --- a/cupertino_store/step_06/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/cupertino_store/step_06/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/cupertino_store/step_06/lib/app.dart b/cupertino_store/step_06/lib/app.dart index ad335f7810..993f086973 100644 --- a/cupertino_store/step_06/lib/app.dart +++ b/cupertino_store/step_06/lib/app.dart @@ -54,7 +54,7 @@ class CupertinoStoreHomePage extends StatelessWidget { ], ), tabBuilder: (context, index) { - CupertinoTabView returnValue; + late final CupertinoTabView returnValue; switch (index) { case 0: returnValue = CupertinoTabView(builder: (context) { diff --git a/cupertino_store/step_06/lib/model/app_state_model.dart b/cupertino_store/step_06/lib/model/app_state_model.dart index b419f96d03..e35429dcaf 100644 --- a/cupertino_store/step_06/lib/model/app_state_model.dart +++ b/cupertino_store/step_06/lib/model/app_state_model.dart @@ -22,7 +22,7 @@ double _shippingCostPerItem = 7; class AppStateModel extends foundation.ChangeNotifier { // All the available products. - List _availableProducts; + List _availableProducts = []; // The currently selected category of products. Category _selectedCategory = Category.all; @@ -49,7 +49,7 @@ class AppStateModel extends foundation.ChangeNotifier { double get subtotalCost { return _productsInCart.keys.map((id) { // Extended price for product line - return getProductById(id).price * _productsInCart[id]; + return getProductById(id).price * _productsInCart[id]!; }).fold(0, (accumulator, extendedPrice) { return accumulator + extendedPrice; }); @@ -75,10 +75,6 @@ class AppStateModel extends foundation.ChangeNotifier { // Returns a copy of the list of available products, filtered by category. List getProducts() { - if (_availableProducts == null) { - return []; - } - if (_selectedCategory == Category.all) { return List.from(_availableProducts); } else { @@ -100,7 +96,7 @@ class AppStateModel extends foundation.ChangeNotifier { if (!_productsInCart.containsKey(productId)) { _productsInCart[productId] = 1; } else { - _productsInCart[productId]++; + _productsInCart[productId] = _productsInCart[productId]! + 1; } notifyListeners(); @@ -112,7 +108,7 @@ class AppStateModel extends foundation.ChangeNotifier { if (_productsInCart[productId] == 1) { _productsInCart.remove(productId); } else { - _productsInCart[productId]--; + _productsInCart[productId] = _productsInCart[productId]! - 1; } } diff --git a/cupertino_store/step_06/lib/model/product.dart b/cupertino_store/step_06/lib/model/product.dart index 159691fe09..a0a5837188 100644 --- a/cupertino_store/step_06/lib/model/product.dart +++ b/cupertino_store/step_06/lib/model/product.dart @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import 'package:flutter/foundation.dart'; - enum Category { all, accessories, @@ -23,16 +21,12 @@ enum Category { class Product { const Product({ - @required this.category, - @required this.id, - @required this.isFeatured, - @required this.name, - @required this.price, - }) : assert(category != null, 'category must not be null'), - assert(id != null, 'id must not be null'), - assert(isFeatured != null, 'isFeatured must not be null'), - assert(name != null, 'name must not be null'), - assert(price != null, 'price must not be null'); + required this.category, + required this.id, + required this.isFeatured, + required this.name, + required this.price, + }); final Category category; final int id; diff --git a/cupertino_store/step_06/lib/product_list_tab.dart b/cupertino_store/step_06/lib/product_list_tab.dart index 595729f046..53ef43568f 100644 --- a/cupertino_store/step_06/lib/product_list_tab.dart +++ b/cupertino_store/step_06/lib/product_list_tab.dart @@ -38,7 +38,6 @@ class ProductListTab extends StatelessWidget { (context, index) { if (index < products.length) { return ProductRowItem( - index: index, product: products[index], lastItem: index == products.length - 1, ); diff --git a/cupertino_store/step_06/lib/product_row_item.dart b/cupertino_store/step_06/lib/product_row_item.dart index 95930d1c38..36ff60f2d9 100644 --- a/cupertino_store/step_06/lib/product_row_item.dart +++ b/cupertino_store/step_06/lib/product_row_item.dart @@ -21,13 +21,11 @@ import 'styles.dart'; class ProductRowItem extends StatelessWidget { const ProductRowItem({ - this.index, - this.product, - this.lastItem, + required this.product, + required this.lastItem, }); final Product product; - final int index; final bool lastItem; @override diff --git a/cupertino_store/step_06/lib/search_bar.dart b/cupertino_store/step_06/lib/search_bar.dart index 4f992f2f67..758bbeca7f 100644 --- a/cupertino_store/step_06/lib/search_bar.dart +++ b/cupertino_store/step_06/lib/search_bar.dart @@ -8,8 +8,8 @@ import 'styles.dart'; class SearchBar extends StatelessWidget { const SearchBar({ - @required this.controller, - @required this.focusNode, + required this.controller, + required this.focusNode, }); final TextEditingController controller; diff --git a/cupertino_store/step_06/lib/search_tab.dart b/cupertino_store/step_06/lib/search_tab.dart index 370f9a3b05..9513351bc7 100644 --- a/cupertino_store/step_06/lib/search_tab.dart +++ b/cupertino_store/step_06/lib/search_tab.dart @@ -28,8 +28,8 @@ class SearchTab extends StatefulWidget { } class _SearchTabState extends State { - TextEditingController _controller; - FocusNode _focusNode; + late final TextEditingController _controller; + late final FocusNode _focusNode; String _terms = ''; @override @@ -78,7 +78,6 @@ class _SearchTabState extends State { Expanded( child: ListView.builder( itemBuilder: (context, index) => ProductRowItem( - index: index, product: results[index], lastItem: index == results.length - 1, ), diff --git a/cupertino_store/step_06/lib/shopping_cart_tab.dart b/cupertino_store/step_06/lib/shopping_cart_tab.dart index 3f230c8122..8b13bdd717 100644 --- a/cupertino_store/step_06/lib/shopping_cart_tab.dart +++ b/cupertino_store/step_06/lib/shopping_cart_tab.dart @@ -30,10 +30,10 @@ class ShoppingCartTab extends StatefulWidget { } class _ShoppingCartTabState extends State { - String name; - String email; - String location; - String pin; + String? name; + String? email; + String? location; + String? pin; DateTime dateTime = DateTime.now(); final _currencyFormat = NumberFormat.currency(symbol: '\$'); @@ -251,11 +251,11 @@ class _ShoppingCartTabState extends State { class ShoppingCartItem extends StatelessWidget { const ShoppingCartItem({ - @required this.index, - @required this.product, - @required this.lastItem, - @required this.quantity, - @required this.formatter, + required this.index, + required this.product, + required this.lastItem, + required this.quantity, + required this.formatter, }); final Product product; diff --git a/cupertino_store/step_06/pubspec.lock b/cupertino_store/step_06/pubspec.lock index d12693e20e..fb2c61b5f4 100644 --- a/cupertino_store/step_06/pubspec.lock +++ b/cupertino_store/step_06/pubspec.lock @@ -7,42 +7,42 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.3" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.5" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.5" + version: "1.15.0" cupertino_icons: dependency: "direct main" description: @@ -56,7 +56,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -73,56 +73,56 @@ packages: name: intl url: "https://pub.dartlang.org" source: hosted - version: "0.16.1" + version: "0.17.0" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.3" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.6" + version: "1.3.0" nested: dependency: transitive description: name: nested url: "https://pub.dartlang.org" source: hosted - version: "0.0.4" + version: "1.0.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.3" + version: "1.8.0" pedantic: dependency: "direct dev" description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.9.2" + version: "1.10.0" provider: dependency: "direct main" description: name: provider url: "https://pub.dartlang.org" source: hosted - version: "4.3.2+4" + version: "5.0.0-nullsafety.4" shrine_images: dependency: "direct main" description: name: shrine_images url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "2.0.1" sky_engine: dependency: transitive description: flutter @@ -134,56 +134,56 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.4" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.6" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.6" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.5" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.5" + version: "2.1.0" sdks: - dart: ">=2.12.0-0.0 <3.0.0" + dart: ">=2.12.0-259.8.beta <3.0.0" flutter: ">=1.16.0" diff --git a/cupertino_store/step_06/pubspec.yaml b/cupertino_store/step_06/pubspec.yaml index b267d7b0df..6c80e2ef53 100644 --- a/cupertino_store/step_06/pubspec.yaml +++ b/cupertino_store/step_06/pubspec.yaml @@ -18,20 +18,20 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.7.0 <3.0.0" + sdk: ">=2.12.0-259.8.beta <3.0.0" dependencies: - cupertino_icons: ^1.0.0 + cupertino_icons: ^1.0.2 flutter: sdk: flutter - intl: ^0.16.1 - provider: ^4.1.1 - shrine_images: ^1.0.0 + intl: ^0.17.0 + provider: ^5.0.0-0 + shrine_images: ^2.0.1 dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.9.0 + pedantic: ^1.10.0 flutter: assets: diff --git a/flutter_ci_script_stable.sh b/flutter_ci_script_stable.sh index 2563324c00..38c4831e5e 100755 --- a/flutter_ci_script_stable.sh +++ b/flutter_ci_script_stable.sh @@ -21,7 +21,8 @@ declare -a CODELABS=( "add_flutter_to_android_app" # TODO(domesticmouse): Uncomment at next Flutter stable roll # "cookbook" - "cupertino_store" + # TODO(domesticmouse): Uncomment once null safety becomes stable + # "cupertino_store" "firebase-get-to-know-flutter" "github-graphql-client" "google-maps-in-flutter"