Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref.watch(myProvider) is only disposing the provider when myProvider changed but not re-building it again #3774

Closed
nateshmbhat opened this issue Oct 12, 2024 · 2 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@nateshmbhat
Copy link

Describe the bug
ref.watch(myProvider) is only disposing the provider when myProvider changed but not re-building it again

Initially when the app launches : i read this profileStatsInfoProvider by doing :
ref.read(profileStatsInfoProvider) in my App widget inside the initState method. Though this is a FutureProvider it gets evaluated and I see logs which says reevaluating.

After a second, myProvider gets updated which causes the profileStatsInfoProvider also to get disposed right away. But what i'm expecting is that since its a FutureProvider and not an AutoDisposeFutureProvider , it should also get re-evaluated right away.

When i open a screen in the app which depends on this provider, then it reevaluates fresh.

To Reproduce

final profileStatsInfoProvider =  FutureProvider<ProfileStatsResponseModel>((ref) async {
  print('reevaluating');
  ref.watch(myProvider);
  return api.getProfileInfo(userId: 'id');
});

Expected behavior :
when myProvider gets updated which causes the profileStatsInfoProvider also to get disposed, Expected behavior is that it profileStatsInfoProvider should get re-evaluated right away.

@rrousselGit
Copy link
Owner

Same thing with your invalidateSelf issue:

The provider needs to be listened for the refresh to happen.
You only mentioned that you used ref.read to use that provider. As such, your provider is likely never listened, so will not refresh.

@rrousselGit rrousselGit added question Further information is requested and removed needs triage labels Oct 12, 2024
@nateshmbhat
Copy link
Author

thanks. closing this issue as my question is discussed in more detail in previous issue : #3773

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants