Reputation: 5942
I am using Riverpod and I want to use AsyncNotifier, In this provider is used Async value as a default state, I have created my State and I want to use my state instead of the default one.
How can I use my state instead of the default async value notifier?
@riverpod
class ExploreController extends _$ExploreController {
@override
Future<UIState<ExploreModel>> build() async {
final result = await getExploreModel();
return UIState.success(data: result);
}
Upvotes: 1
Views: 788
Reputation: 8529
You can disable conversion of a Stream
/Future
to AsyncValue
using the Raw
typedef.
Raw<Future<UIState<ExploreModel>>> build() async {
// ...
}
Please note that it is generally discouraged to disable the AsyncValue
conversion.
More about the Raw
typedef: https://riverpod.dev/docs/essentials/websockets_sync#disabling-conversion-of-streamsfutures-to-asyncvalue
Upvotes: 2