riverpod icon indicating copy to clipboard operation
riverpod copied to clipboard

`ref.invalidate(familyProvider)` is not working with scoped providers

Open thiagokisaki opened this issue 1 month ago • 0 comments

Describe the bug ref.invalidate(familyProvider) doesn't seem to work properly when using scoped providers. The problem happens when nesting a ProviderScope inside others.

The reason I'm using many ProviderScopes is that I want to override providers dynamically based on a runtime check. For example, switch from a network and a local implementation of a service, in an app that works both offline with a local database or consuming an API.

I am not sure if this is a bug or a misunderstanding from my part. If I am wrong, I'd appreciate feedback on what I could do to fix the problem.

To Reproduce I created a simple todo app to demonstrate the problem. Please read the comments in the code. https://dartpad.dev/?id=b0cbe8e4d8869e181df00ebd5873c0cc

Expected behavior I expect ref.invalidate(familyProvider) to work even when using scoped providers.

thiagokisaki avatar May 21 '24 20:05 thiagokisaki