Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f3722f3
Migrate step_06 to null safety
domesticmouse Feb 8, 2021
47ab40d
Migrate step_05 to null safety
domesticmouse Feb 8, 2021
bd6a5cb
Migrate step_04 to null safety
domesticmouse Feb 8, 2021
a391e5e
Migrate step_03 to null safety
domesticmouse Feb 8, 2021
02cdf87
Migrate step_02 to null safety
domesticmouse Feb 8, 2021
3be6608
Migrate step_01 to null safety
domesticmouse Feb 8, 2021
ab0792e
Migrate step_00 to null safety
domesticmouse Feb 8, 2021
71e0434
Drop cupertino_store from stable
domesticmouse Feb 8, 2021
6b5aace
Merge branch 'master' of https://github.com/flutter/codelabs into cup…
domesticmouse Feb 9, 2021
0f2233c
late final ftw
domesticmouse Feb 9, 2021
d69350f
late final pt2
domesticmouse Feb 9, 2021
94ed93f
Merge branch 'master' of https://github.com/flutter/codelabs into cup…
domesticmouse Feb 19, 2021
b0ac93c
flutter pub upgrade
domesticmouse Feb 19, 2021
f58713b
Merge branch 'master' of https://github.com/flutter/codelabs into cup…
domesticmouse Feb 19, 2021
e0a1d62
Update pubspec dep versions
domesticmouse Feb 19, 2021
ed895c8
Merge branch 'master' of https://github.com/flutter/codelabs into cup…
domesticmouse Mar 1, 2021
bf4d901
Merge branch 'cupertino-store-null-safety' of https://github.com/dome…
domesticmouse Mar 1, 2021
26023ae
Simplify provider dependency
domesticmouse Mar 2, 2021
af9c34e
provider dep
domesticmouse Mar 2, 2021
129d74b
provider dep
domesticmouse Mar 2, 2021
36a9c8e
provider dep
domesticmouse Mar 2, 2021
e5a2bf7
pedantic dep
domesticmouse Mar 2, 2021
f8f0437
pedantic dep
domesticmouse Mar 2, 2021
4a67e92
provider dep
domesticmouse Mar 2, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 24 additions & 24 deletions cupertino_store/step_00/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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"
12 changes: 6 additions & 6 deletions cupertino_store/step_00/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cupertino_store/step_01/lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CupertinoStoreHomePage extends StatelessWidget {
],
),
tabBuilder: (context, index) {
CupertinoTabView returnValue;
late final CupertinoTabView returnValue;
Copy link
Member

@miquelbeltran miquelbeltran Feb 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edited

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, I copied the wrong code example, indeed with "late" the default case is not necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm glad it all worked out in the end =)

switch (index) {
case 0:
returnValue = CupertinoTabView(builder: (context) {
Expand Down
12 changes: 4 additions & 8 deletions cupertino_store/step_01/lib/model/app_state_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ double _shippingCostPerItem = 7;

class AppStateModel extends foundation.ChangeNotifier {
// All the available products.
List<Product> _availableProducts;
List<Product> _availableProducts = [];

// The currently selected category of products.
Category _selectedCategory = Category.all;
Expand 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;
});
Expand All @@ -75,10 +75,6 @@ class AppStateModel extends foundation.ChangeNotifier {

// Returns a copy of the list of available products, filtered by category.
List<Product> getProducts() {
if (_availableProducts == null) {
return [];
}

if (_selectedCategory == Category.all) {
return List.from(_availableProducts);
} else {
Expand All @@ -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();
Expand All @@ -112,7 +108,7 @@ class AppStateModel extends foundation.ChangeNotifier {
if (_productsInCart[productId] == 1) {
_productsInCart.remove(productId);
} else {
_productsInCart[productId]--;
_productsInCart[productId] = _productsInCart[productId]! - 1;
}
}

Expand Down
18 changes: 6 additions & 12 deletions cupertino_store/step_01/lib/model/product.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down
Loading