How do I use overrideWithValue the same way overrideWithProvider was used? (v 1.x) #788
Answered
by
rrousselGit
ketanchoyal
asked this question in
Q&A
-
I'm using riverpod v1.x for my apps and in the latest dev release overrideWithProvider is removed, I have a provider in the client package which I have override to the following provider:
I have to pass the Reader function to the init constructor which I don't know how do I pass when I use overrideWithValue I've used overrideWithProvider very extensively so any suggestions will be appreciated |
Beta Was this translation helpful? Give feedback.
Answered by
rrousselGit
Oct 5, 2021
Replies: 1 comment 1 reply
-
Rather than overriding the provider, you can override one of its dependency So if needed, you could split your provider to allow overriding, such as: final secretProvider = Provider<String>(...)
StateNotifierProvider<Client, ClientProps>((ref) {
return Client.init(
...
secretBox: ref.watch(secret),
);
});
...
ProviderScope(
overrides: [secretProvider.overrideWithValue(HiveStore.secret)],
) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ketanchoyal
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rather than overriding the provider, you can override one of its dependency
So if needed, you could split your provider to allow overriding, such as: