Replies: 1 comment
-
I think I understand what's happening now, the issue is fixed by reading the state directly inside the hook. |
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
-
So, here is my code where only the relevant part is kept:
Those 2 prints methods output the following results:
flutter: Inside the hook, state is AsyncLoading
flutter: Outside the hook, state is AsyncData (or whatever is the actual state of the provider)
Also, the return widget do update accordingly to the actual state of the provider, but somehow, inside the hook, the state is always an AsyncLoading.
My need to read the state within the hook is so that I can prevent repeated calls to the feedProvider (don't call if either loading or error).
Of course, in my real code, I use state.hasError, state.isLoading but here, I made this just to test since the actual code didn't work as state.isLoading was always and constantly true despite checking outside he hook gives me the actual different states.
Is there something inherently wrong with my code or something I am missing?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions