Skip to content

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
Discussion options

You must be logged in to vote

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)],
)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ketanchoyal
Comment options

Answer selected by ketanchoyal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants