-
Assume I have
In
In
When Question:1. How to trigger |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 26 replies
-
Your build method should be changed like this Future<MovieState> build() async {
final repository = ref.watch(movieRepositoryProvider);
final response = await repository.fetchMovies();
return MovieState(movies: response);
} Loading and error associated with Future calls gets automatically handled inside build method of AsyncNotifier |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
@phamquoctrongnta Your English is good. English is not my first language either so we are on the same side :)
What I was trying to tell you was that
throw
ingException
was a valid way of returning details of error.throw
is more suitable thanreturn
for exceptions because IDE can jump to where exception has occurred, which means it's more developer friendly. If you just returnException
as you mention, you need to handle manually insidebuild
method of Notifier and it gets harder to track where theException
originates from.