Having issue while creating multiple instances of a single provider used by a widget, and that widget is used multiple times on a single page. #3536
umersaddiq
started this conversation in
General
Replies: 2 comments
-
I suppose providers are not generic-aware. Do you really need a provider to store the state of the widget? You could pass a ValueNotifier as parameter to your widget, perhaps created with Also the widget does not need to be stateful. A ConsumerWidget would suffice. |
Beta Was this translation helpful? Give feedback.
0 replies
-
@gdurandrexel riverpod version 3.0.0-dev.3 Supports generics. I want to do this using riverpod, and I don't want to use ValueNotifier or HookConsumerWidget. |
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
-
Hi. I'm having a problem with using Riverpod
I have created reusable widget using generics, and to maintain their state, I have created a provider, as you can see in the code.
Now, the issue is that when I use this widget multiple times along with its provider, only a single instance of the provider gets created, which is then used by both widgets. Since I am assigning different Enums to T, why does only a single instance of the provider get created? How can I tackle this issue?
Beta Was this translation helpful? Give feedback.
All reactions