use riverpod in custom hooks

Viewed 171

I want to create a custom useMyAccount hook in my application, that should return a watcher or my account.

I am using riverpod to manage the account state.

But this code does not work:

StateNotifierProvider<MyAccountProvider, MyAccount?>? useMyAccount(WidgetRef ref) {
  return ref.watch(myAccountProvider);
}

I know that there is the package hooks_riverpod and I am using it, but (contrary to the docs and examples) they removed the useProvider hook in the latest version and for some reason whenever I use WidgetRef ref as a param for the hook, the type BaseProvider is always added to my return type.

How can I create a hook that watches and returns my account?

0 Answers
Related