Unnecessary api call on invalidating a provider #3548
Unanswered
yasiralijaved
asked this question in
Q&A
Replies: 2 comments 3 replies
-
The |
Beta Was this translation helpful? Give feedback.
3 replies
-
ref.invalidate(profileProvider);
ref.invalidate(projectListProvider);
ref.read(accessTokenProvider.notifier).logout(); This should be done in a declarative way. Your When the login state changes, those providers will be recomputed. |
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 i am using ProfileProvider to fetch the user profile from rest api.
On logout when i try to invalidate the the profile provider, the build() of profile provider called thus calling the api again. This is because the value of profile provider is still being watched in HomeWidget until the HomeWidget gets destroyed and LoginWidget comes up.
I know this can be avoided if there is no watcher available for this profile provider. But there is no way i can unsubscribe from profile provider in the HomeWidget.
I want to avoid the build() being called on logout. Help is required.
Beta Was this translation helpful? Give feedback.
All reactions