From e5b026c2629d4d8a3f62f53d593e6270ec26834e Mon Sep 17 00:00:00 2001 From: Ryo Takeuchi Date: Mon, 25 Sep 2023 09:11:16 +0900 Subject: [PATCH] =?UTF-8?q?improve:=20=E4=B8=8D=E8=A6=81=E3=81=AA=20Future?= =?UTF-8?q?=20=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/features/sponsor/data/sponsor_data_source.dart | 2 +- lib/features/sponsor/data/sponsor_provider.dart | 6 +++--- lib/features/sponsor/data/sponsor_provider.g.dart | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/features/sponsor/data/sponsor_data_source.dart b/lib/features/sponsor/data/sponsor_data_source.dart index a96e00f1..09d1f53f 100644 --- a/lib/features/sponsor/data/sponsor_data_source.dart +++ b/lib/features/sponsor/data/sponsor_data_source.dart @@ -11,7 +11,7 @@ SponsorDataSource sponsorDataSource(SponsorDataSourceRef ref) => SponsorDataSource(); final class SponsorDataSource { - Future> fetchSponsors() async { + List fetchSponsors() { return [ ..._platinumSponsors, ..._goldSponsors, diff --git a/lib/features/sponsor/data/sponsor_provider.dart b/lib/features/sponsor/data/sponsor_provider.dart index d8b73e03..3ed800ef 100644 --- a/lib/features/sponsor/data/sponsor_provider.dart +++ b/lib/features/sponsor/data/sponsor_provider.dart @@ -6,11 +6,11 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'sponsor_provider.g.dart'; @riverpod -Future> sponsors(SponsorsRef ref) => +List sponsors(SponsorsRef ref) => ref.watch(sponsorDataSourceProvider).fetchSponsors(); @riverpod -Future sponsor(SponsorRef ref, String name) async { - final sponsors = await ref.watch(sponsorsProvider.future); +Sponsor? sponsor(SponsorRef ref, String name) { + final sponsors = ref.watch(sponsorsProvider); return sponsors.firstWhereOrNull((element) => name == element.name); } diff --git a/lib/features/sponsor/data/sponsor_provider.g.dart b/lib/features/sponsor/data/sponsor_provider.g.dart index ff53a23a..551ab6e0 100644 --- a/lib/features/sponsor/data/sponsor_provider.g.dart +++ b/lib/features/sponsor/data/sponsor_provider.g.dart @@ -8,11 +8,11 @@ part of 'sponsor_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$sponsorsHash() => r'd918d840139ddd7ed5a2a2fdad722095fe3c46e6'; +String _$sponsorsHash() => r'a6254993ff1fc8e671a043c8aa2a0eb9df3c648e'; /// See also [sponsors]. @ProviderFor(sponsors) -final sponsorsProvider = AutoDisposeFutureProvider>.internal( +final sponsorsProvider = AutoDisposeProvider>.internal( sponsors, name: r'sponsorsProvider', debugGetCreateSourceHash: @@ -21,8 +21,8 @@ final sponsorsProvider = AutoDisposeFutureProvider>.internal( allTransitiveDependencies: null, ); -typedef SponsorsRef = AutoDisposeFutureProviderRef>; -String _$sponsorHash() => r'd258b678c979c5c0d98a9e6a62d5d29e1489105a'; +typedef SponsorsRef = AutoDisposeProviderRef>; +String _$sponsorHash() => r'5417463db69173e5648d78be4ca790e14a145423'; /// Copied from Dart SDK class _SystemHash { @@ -45,14 +45,14 @@ class _SystemHash { } } -typedef SponsorRef = AutoDisposeFutureProviderRef; +typedef SponsorRef = AutoDisposeProviderRef; /// See also [sponsor]. @ProviderFor(sponsor) const sponsorProvider = SponsorFamily(); /// See also [sponsor]. -class SponsorFamily extends Family> { +class SponsorFamily extends Family { /// See also [sponsor]. const SponsorFamily(); @@ -90,7 +90,7 @@ class SponsorFamily extends Family> { } /// See also [sponsor]. -class SponsorProvider extends AutoDisposeFutureProvider { +class SponsorProvider extends AutoDisposeProvider { /// See also [sponsor]. SponsorProvider( this.name,