'Riverpod base class for WidgetRef and ProviderRef
function(
WidgetRef ref,
// ProviderRef ref,
) {
final a = ref.read(aProvider);
// Some logic
}
What base class that can read WidgetRef and ProviderRef?
Solution 1:[1]
Apparently it's been answered in here by the creator https://github.com/rrousselGit/riverpod/discussions/1152
However, I wondered why Ref and WidgetRef don't share a common interface?
That's voluntary. The fact that you need a common interface shows a flaw in your architecture
You most definitely did something wrong somewhere. You should never need to use WidgetRef outside of widgets
So, there is no base class or common interface. It's considered there is flaw in your code if you need WidgetRef outside of widgets.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ryde |
