AutoDisposeFamilyNotifier does not cache results for previously used arguments #3961
Unanswered
Velkamhell97
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I want to create a provider that allows me to receive arguments to update the result, similar to
FamilyNotifier, but also a provider that gets disposed once no listeners are attached, such as when I pop the current screen, just likeAutoDisposeNotifier.I'm trying to combine both behaviors using
AutoDisposeFamilyNotifier, but I’ve noticed that it doesn’t work as expected. This provider is disposed of each time I change the argument passed to it, even if the same argument was used before. I’m not sure if this is the intended behavior, but ideally, I would like the provider to be disposed of only when I pop the current screen.My goal is to create a new state each time I navigate to the screen where this provider is used, cache results for arguments that have already been passed, and dispose the provider when I pop the current screen.
Is there a way to achieve this? I tried using
ref.keepAlive, but this essentially turnsAutoDisposeFamilyNotifierinto aFamilyNotifier, preventing the provider from being disposed of when I pop the screen.I’ve included a minimal example to illustrate the issue more clearly.
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions