From cb1eeaa07628af3212faa2b2698ae17ab75125da Mon Sep 17 00:00:00 2001 From: yorifuji Date: Sat, 23 Dec 2023 00:14:46 +0900 Subject: [PATCH 1/4] ci: Update workflow to include custom lint --- .github/workflows/check.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 501091a2..0a750550 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -69,10 +69,14 @@ jobs: - run: flutter analyze --write=flutter_analyze.log - - uses: yorifuji/flutter-analyze-commenter@v1 + - if: ${{ !cancelled() }} + run: dart run custom_lint --format=json > custom_lint.json + + - uses: yorifuji/flutter-analyze-commenter@develop if: ${{ !cancelled() }} with: - analyze_log: flutter_analyze.log + analyze-log: flutter_analyze.log + custom-lint-log: custom_lint.json verbose: true # diff: From af3bd1f2ef42f2300cd81cfa1b739cc13bf266d4 Mon Sep 17 00:00:00 2001 From: yorifuji Date: Sat, 23 Dec 2023 01:28:43 +0900 Subject: [PATCH 2/4] wip --- lib/i18n/strings.g.dart | 2 +- lib/store/recipe_store2.dart | 36 ++++++++++++++++++++++++++++++++++ lib/store/recipe_store2.g.dart | 27 +++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 lib/store/recipe_store2.dart create mode 100644 lib/store/recipe_store2.g.dart diff --git a/lib/i18n/strings.g.dart b/lib/i18n/strings.g.dart index e88a1635..3aa65d34 100644 --- a/lib/i18n/strings.g.dart +++ b/lib/i18n/strings.g.dart @@ -6,7 +6,7 @@ /// Locales: 2 /// Strings: 108 (54 per locale) /// -/// Built on 2023-12-17 at 01:21 UTC +/// Built on 2023-12-22 at 16:28 UTC // coverage:ignore-file // ignore_for_file: type=lint diff --git a/lib/store/recipe_store2.dart b/lib/store/recipe_store2.dart new file mode 100644 index 00000000..e849e661 --- /dev/null +++ b/lib/store/recipe_store2.dart @@ -0,0 +1,36 @@ +import 'package:buzz_recipe_viewer/model/recipe.dart'; +import 'package:buzz_recipe_viewer/store/favorite_store.dart'; +import 'package:buzz_recipe_viewer/store/search_hit_store.dart'; +import 'package:collection/collection.dart'; +import 'package:mockito/mockito.dart'; +import 'package:riverpod_annotation/riverpod_annotation.dart'; + +part 'recipe_store2.g.dart'; + +@riverpod +class RecipeStore2 extends _$RecipeStore2 { + @override + List build() { + final searchHitList = ref.watch(searchHitStoreProvider); + final favoriteList = ref.watch(favoriteStoreProvider); + + if (favoriteList.isEmpty) { + return searchHitList.map((e) => Recipe(searchHit: e)).toList(); + } else { + return searchHitList.map((searchHit) { + final favorite = favoriteList.firstWhereOrNull( + (favorite) => favorite.searchHitId == searchHit.id, + ); + return Recipe( + searchHit: searchHit, + favorite: favorite, + ); + }).toList(); + } + } +} + +class FakeRecipeStore extends _$RecipeStore with Mock implements RecipeStore2 { + @override + List build() => []; +} diff --git a/lib/store/recipe_store2.g.dart b/lib/store/recipe_store2.g.dart new file mode 100644 index 00000000..7eed360c --- /dev/null +++ b/lib/store/recipe_store2.g.dart @@ -0,0 +1,27 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ignore_for_file: implicit_dynamic_parameter, implicit_dynamic_type, implicit_dynamic_method, strict_raw_type + +part of 'recipe_store2.dart'; + +// ************************************************************************** +// RiverpodGenerator +// ************************************************************************** + +String _$recipeStore2Hash() => r'd52e1281e4b3ed61e605bd7241c933ef56209581'; + +/// See also [RecipeStore2]. +@ProviderFor(RecipeStore2) +final recipeStore2Provider = + AutoDisposeNotifierProvider>.internal( + RecipeStore2.new, + name: r'recipeStore2Provider', + debugGetCreateSourceHash: + const bool.fromEnvironment('dart.vm.product') ? null : _$recipeStore2Hash, + dependencies: null, + allTransitiveDependencies: null, +); + +typedef _$RecipeStore2 = AutoDisposeNotifier>; +// ignore_for_file: type=lint +// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member From f940f7b9439694930a8e0aef0c3d826aa0fbb7b9 Mon Sep 17 00:00:00 2001 From: yorifuji Date: Sat, 23 Dec 2023 10:13:51 +0900 Subject: [PATCH 3/4] ci: Update action version and fix class inheritance --- .github/workflows/check.yml | 2 +- lib/store/recipe_store2.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 0a750550..b5236ff4 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -72,7 +72,7 @@ jobs: - if: ${{ !cancelled() }} run: dart run custom_lint --format=json > custom_lint.json - - uses: yorifuji/flutter-analyze-commenter@develop + - uses: yorifuji/flutter-analyze-commenter@v1 if: ${{ !cancelled() }} with: analyze-log: flutter_analyze.log diff --git a/lib/store/recipe_store2.dart b/lib/store/recipe_store2.dart index e849e661..b34d78e5 100644 --- a/lib/store/recipe_store2.dart +++ b/lib/store/recipe_store2.dart @@ -30,7 +30,7 @@ class RecipeStore2 extends _$RecipeStore2 { } } -class FakeRecipeStore extends _$RecipeStore with Mock implements RecipeStore2 { +class FakeRecipeStore extends _$RecipeStore2 with Mock implements RecipeStore2 { @override List build() => []; } From 51470059fe797568006c66efd25cd32de976437b Mon Sep 17 00:00:00 2001 From: yorifuji Date: Sat, 23 Dec 2023 10:19:32 +0900 Subject: [PATCH 4/4] refactor: Add missing variable initialization --- lib/main.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/main.dart b/lib/main.dart index 52177c0d..2efc3016 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -14,6 +14,7 @@ import 'package:path_provider/path_provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; void main() async { + final String x = 0; WidgetsFlutterBinding.ensureInitialized(); final (_, isar, packageInfo, sharedPreferences) = await (