combining AsyncNotifier state and prevent unwanted AsyncLoading #3022
solaristhesun
started this conversation in
General
Replies: 3 comments 1 reply
-
This behavior will be fixed by #2797 Currently, you can just skip when state is reLoading and value is not null. container.listen(filteredListProvider, (previous, next) {
if(next.isReloading && next.hasValue) return;
debugPrint("filteredListProvider: $previous -> $next");
}); |
Beta Was this translation helpful? Give feedback.
1 reply
-
You're free to set Since you have access to the previous value/error, that should be doable. build() async {
// Remove loading state from refreshes/reloads
if (state.hasError) state = AsyncError(state.error!, state.stackTrace!);
else if (state.hasData) state = AsyncData(state.requireValue);
await whatever();
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
Ok, I see. Thank you both for your answers. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What is the correct way to combine state of AsyncNotifier states? The problem with my code is that after calling addValue() the FilteredNotifier state changes to AsyncLoading() before it shows the filtered list. Can this be prevented?
The output is:
Beta Was this translation helpful? Give feedback.
All reactions