riverpod icon indicating copy to clipboard operation
riverpod copied to clipboard

Providers dispose after log out

Open henriqueArrazao opened this issue 2 weeks ago • 0 comments

I have a "SessionNotifier" (stores userToken and Firebase remote config data for example) that should never be disposed. So it is inside of the first Scope. I have another ProviderScope for the HomeScreen (when the user is already logged). So I thought, when the HomeScreen is disposed, all the providers with the stored data of the user, e.g. "to do" list, "categories" list, etc would be disposed as well. But it does not happen. So I started using the "UncontrolledProviderScope", but now, but the only disposed providers are the ones in HomePage, ignoring the ones of further screens. So I would need to wrap every single route in a scope? And another thing, I needed to create a GlobalKey to access the providers from previous Scopes, otherwise it would duplicate them. Either I'm not used to the way RiverPod manages this (I used to be very happy using the GetIt scopes), or I find their behavior very strange. Basically, how do I make to all providers created after the login to be disposed in the "riverpod way"? Is there any example out there? Thanks.

henriqueArrazao avatar Jun 18 '24 15:06 henriqueArrazao