WidgetRef 和 ProviderRef 的 Riverpod 基础 class

Riverpod base class for WidgetRef and ProviderRef

function(
  WidgetRef ref, 
  // ProviderRef ref,
) {
  final a = ref.read(aProvider);
  // Some logic
}

哪个库class可以读取WidgetRef和ProviderRef?

显然创建者已经在这里回答了 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

因此,没有基础 class 或通用接口。如果您需要 widgets 之外的 WidgetRef,则认为您的代码存在缺陷。