Skip to content

Commit

Permalink
fix: summary card with no category (#1107)
Browse files Browse the repository at this point in the history
* fix: summary card with no category #1106

* suggestion from code review by @monsieurtanuki
  • Loading branch information
stephanegigandet authored Feb 11, 2022
1 parent 6b1c6ff commit f1777e8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
18 changes: 14 additions & 4 deletions packages/smooth_app/lib/pages/product/summary_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,19 @@ class _SummaryCardState extends State<SummaryCard> {
margin: const EdgeInsets.only(bottom: 16),
child: Column(children: displayedGroups),
);
final String? categoryTag = widget._product.categoriesTags?.last;
final String? categoryLabel = widget
._product.categoriesTagsInLanguages?[ProductQuery.getLanguage()!]?.last;
String? categoryTag;
String? categoryLabel;
if (widget._product.categoriesTags?.isNotEmpty ?? false) {
categoryTag = widget._product.categoriesTags!.last;
if (widget
._product
.categoriesTagsInLanguages?[ProductQuery.getLanguage()!]
?.isNotEmpty ??
false) {
categoryLabel = widget._product
.categoriesTagsInLanguages![ProductQuery.getLanguage()!]!.last;
}
}
return Column(
children: <Widget>[
ProductTitleCard(widget._product),
Expand All @@ -247,7 +257,7 @@ class _SummaryCardState extends State<SummaryCard> {
onPressed: () async => ProductQueryPageHelper().openBestChoice(
color: Colors.deepPurple,
heroTag: 'search_bar',
name: categoryLabel,
name: categoryLabel!,
localDatabase: localDatabase,
productQuery: CategoryProductQuery(
categoryTag: widget._product.categoriesTags!.last,
Expand Down
20 changes: 10 additions & 10 deletions packages/smooth_app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ packages:
name: camera_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.1+1"
version: "0.2.1+2"
carousel_slider:
dependency: "direct main"
description:
Expand Down Expand Up @@ -643,7 +643,7 @@ packages:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
version: "2.0.9"
path_provider_android:
dependency: transitive
description:
Expand Down Expand Up @@ -825,28 +825,28 @@ packages:
name: shared_preferences_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.10"
version: "2.0.11"
shared_preferences_ios:
dependency: transitive
description:
name: shared_preferences_ios
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.9"
version: "2.0.10"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
version: "2.1.0"
shared_preferences_macos:
dependency: transitive
description:
name: shared_preferences_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
version: "2.0.3"
shared_preferences_platform_interface:
dependency: transitive
description:
Expand All @@ -867,7 +867,7 @@ packages:
name: shared_preferences_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
version: "2.1.0"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -998,14 +998,14 @@ packages:
name: url_launcher_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
version: "3.0.0"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
version: "3.0.0"
url_launcher_platform_interface:
dependency: transitive
description:
Expand All @@ -1026,7 +1026,7 @@ packages:
name: url_launcher_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
version: "3.0.0"
uuid:
dependency: "direct main"
description:
Expand Down

0 comments on commit f1777e8

Please sign in to comment.