'Combining good old providers with Riverpod

I have an existing app that implements provider pattern. A sample provider would be:

class SampleProvider {
    static SampleProvider of(BuildContext context) => Provider.of<SampleProvider>(context);
}

Is it somehow possible to use this provider in a Riverpod notifier say something like:

class StateProvider extends StateNotifier<int> {
  StateProvider(int state, SampleProvider provider) : super(state);
}

final provider = StateNotifierProvider<StateProvider, int>((ref) => StateProvider(1, Somehow pass the Sample provider here));

In this case my StateProvider depends on SampleProvider but I cannot access it without a build context.

So the questions here are

  1. Is it a good idea to mix classic providers with riverpod?
  2. Is it possible to pass a classic provider instance of a state notifier say?


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source