From 9ad796c20b00b383232edba7b0cc451f49d7154d Mon Sep 17 00:00:00 2001 From: yorifuji Date: Sat, 6 Apr 2024 23:43:25 +0900 Subject: [PATCH] refactor: Specify dependencies for Riverpod annotations --- lib/provider/package_info_provider.dart | 2 +- lib/repository/favorite_repository.dart | 4 ++-- lib/repository/recipe_note_repository.dart | 4 ++-- lib/service/favorite_service.dart | 2 +- lib/service/recipe_note_service.dart | 2 +- lib/ui/recipe_note/edit/recipe_note_edit_view_model.dart | 2 +- lib/ui/search/search_view_model.dart | 2 +- lib/ui/settings/settings_view_model.dart | 2 +- test/golden_test/favorite_page_golden_test.dart | 1 - test/golden_test/recipe_note_edit_page_golden_test.dart | 1 - test/golden_test/recipe_note_page_golden_test.dart | 1 - test/golden_test/search_page_golden_test.dart | 1 - test/golden_test/settings_page_golden_test.dart | 1 - 13 files changed, 10 insertions(+), 15 deletions(-) diff --git a/lib/provider/package_info_provider.dart b/lib/provider/package_info_provider.dart index 9a8c392e..40ec2d62 100644 --- a/lib/provider/package_info_provider.dart +++ b/lib/provider/package_info_provider.dart @@ -3,5 +3,5 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'package_info_provider.g.dart'; -@riverpod +@Riverpod(dependencies: []) PackageInfo packageInfo(PackageInfoRef ref) => throw UnimplementedError(); diff --git a/lib/repository/favorite_repository.dart b/lib/repository/favorite_repository.dart index b02f1ebb..a8724c08 100644 --- a/lib/repository/favorite_repository.dart +++ b/lib/repository/favorite_repository.dart @@ -7,7 +7,7 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'favorite_repository.g.dart'; -@riverpod +@Riverpod(dependencies: []) FavoriteRepository favoriteRepository(FavoriteRepositoryRef ref) => FavoriteRepository(ref.watch(databaseProvider)); @@ -51,7 +51,7 @@ class FavoriteRepository { } } -@riverpod +@Riverpod(dependencies: []) Stream> favoriteStream(FavoriteStreamRef ref) { final database = ref.watch(databaseProvider); final query = database.select(database.favoriteDB) diff --git a/lib/repository/recipe_note_repository.dart b/lib/repository/recipe_note_repository.dart index 1c129ba4..8747734e 100644 --- a/lib/repository/recipe_note_repository.dart +++ b/lib/repository/recipe_note_repository.dart @@ -7,7 +7,7 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'recipe_note_repository.g.dart'; -@riverpod +@Riverpod(dependencies: []) RecipeNoteRepository recipeNoteRepository(RecipeNoteRepositoryRef ref) => RecipeNoteRepository(ref.watch(databaseProvider)); @@ -43,7 +43,7 @@ class RecipeNoteRepository { } } -@riverpod +@Riverpod(dependencies: []) Stream> recipeNoteStream(RecipeNoteStreamRef ref) { final database = ref.watch(databaseProvider); final query = database.select(database.recipeNoteDB) diff --git a/lib/service/favorite_service.dart b/lib/service/favorite_service.dart index 843e73d4..f20d5f3a 100644 --- a/lib/service/favorite_service.dart +++ b/lib/service/favorite_service.dart @@ -5,7 +5,7 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'favorite_service.g.dart'; -@riverpod +@Riverpod(dependencies: [FavoriteRepository]) FavoriteService favoriteService(FavoriteServiceRef ref) => FavoriteService(ref.watch(favoriteRepositoryProvider)); diff --git a/lib/service/recipe_note_service.dart b/lib/service/recipe_note_service.dart index 400fb7f7..876d5ecb 100644 --- a/lib/service/recipe_note_service.dart +++ b/lib/service/recipe_note_service.dart @@ -5,7 +5,7 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'recipe_note_service.g.dart'; -@riverpod +@Riverpod(dependencies: [RecipeNoteRepository]) RecipeNoteService recipeNoteService(RecipeNoteServiceRef ref) => RecipeNoteService(ref.watch(recipeNoteRepositoryProvider)); diff --git a/lib/ui/recipe_note/edit/recipe_note_edit_view_model.dart b/lib/ui/recipe_note/edit/recipe_note_edit_view_model.dart index ad83b4c1..69f63970 100644 --- a/lib/ui/recipe_note/edit/recipe_note_edit_view_model.dart +++ b/lib/ui/recipe_note/edit/recipe_note_edit_view_model.dart @@ -59,7 +59,7 @@ class RecipeNoteEditState with _$RecipeNoteEditState { bool get isValid => title.isNotEmpty && description.isNotEmpty; } -@riverpod +@Riverpod(dependencies: [RecipeNoteService]) class RecipeNoteEditViewModel extends _$RecipeNoteEditViewModel { late RecipeNoteService _recipeNoteService; @override diff --git a/lib/ui/search/search_view_model.dart b/lib/ui/search/search_view_model.dart index 5bed8a8e..6e51ccee 100644 --- a/lib/ui/search/search_view_model.dart +++ b/lib/ui/search/search_view_model.dart @@ -19,7 +19,7 @@ class SearchState with _$SearchState { }) = _SearchState; } -@riverpod +@Riverpod(dependencies: []) class SearchViewModel extends _$SearchViewModel { late RecipeService _recipeService; @override diff --git a/lib/ui/settings/settings_view_model.dart b/lib/ui/settings/settings_view_model.dart index fdb7203a..ce3ac757 100644 --- a/lib/ui/settings/settings_view_model.dart +++ b/lib/ui/settings/settings_view_model.dart @@ -13,7 +13,7 @@ class SettingsState with _$SettingsState { }) = _SettingsState; } -@riverpod +@Riverpod(dependencies: []) class SettingsViewModel extends _$SettingsViewModel { @override SettingsState build() { diff --git a/test/golden_test/favorite_page_golden_test.dart b/test/golden_test/favorite_page_golden_test.dart index 5a0c9259..b090aeb7 100644 --- a/test/golden_test/favorite_page_golden_test.dart +++ b/test/golden_test/favorite_page_golden_test.dart @@ -1,4 +1,3 @@ -// ignore_for_file: scoped_providers_should_specify_dependencies import 'package:buzz_recipe_viewer/i18n/strings.g.dart'; import 'package:buzz_recipe_viewer/repository/favorite_repository.dart'; import 'package:buzz_recipe_viewer/repository/favorite_repository_mock.dart'; diff --git a/test/golden_test/recipe_note_edit_page_golden_test.dart b/test/golden_test/recipe_note_edit_page_golden_test.dart index 24a6f793..d6ab8cae 100644 --- a/test/golden_test/recipe_note_edit_page_golden_test.dart +++ b/test/golden_test/recipe_note_edit_page_golden_test.dart @@ -1,4 +1,3 @@ -// ignore_for_file: scoped_providers_should_specify_dependencies import 'package:buzz_recipe_viewer/i18n/strings.g.dart'; import 'package:buzz_recipe_viewer/ui/recipe_note/edit/recipe_note_edit_page.dart'; import 'package:buzz_recipe_viewer/ui/recipe_note/edit/recipe_note_edit_view_model.dart'; diff --git a/test/golden_test/recipe_note_page_golden_test.dart b/test/golden_test/recipe_note_page_golden_test.dart index 732570ad..9a151a83 100644 --- a/test/golden_test/recipe_note_page_golden_test.dart +++ b/test/golden_test/recipe_note_page_golden_test.dart @@ -1,4 +1,3 @@ -// ignore_for_file: scoped_providers_should_specify_dependencies import 'package:buzz_recipe_viewer/i18n/strings.g.dart'; import 'package:buzz_recipe_viewer/repository/recipe_note_repository.dart'; import 'package:buzz_recipe_viewer/repository/recipe_note_repository_mock.dart'; diff --git a/test/golden_test/search_page_golden_test.dart b/test/golden_test/search_page_golden_test.dart index 5638ff33..80c68974 100644 --- a/test/golden_test/search_page_golden_test.dart +++ b/test/golden_test/search_page_golden_test.dart @@ -1,4 +1,3 @@ -// ignore_for_file: scoped_providers_should_specify_dependencies import 'package:buzz_recipe_viewer/i18n/strings.g.dart'; import 'package:buzz_recipe_viewer/ui/search/search_page.dart'; import 'package:buzz_recipe_viewer/ui/search/search_view_model.dart'; diff --git a/test/golden_test/settings_page_golden_test.dart b/test/golden_test/settings_page_golden_test.dart index 4aa0d09e..d9572570 100644 --- a/test/golden_test/settings_page_golden_test.dart +++ b/test/golden_test/settings_page_golden_test.dart @@ -1,4 +1,3 @@ -// ignore_for_file: scoped_providers_should_specify_dependencies import 'package:buzz_recipe_viewer/i18n/strings.g.dart'; import 'package:buzz_recipe_viewer/provider/package_info_provider.dart'; import 'package:buzz_recipe_viewer/ui/settings/settings_page.dart';