我有这样的基类和派生类:
abstract class A extends ChangeNotifier{....}
class B extends A{....}
我正在使用这样的提供者:
ChangeNotifierProvider<B>(create: (context) => B())
并像这样使用 A 和 B(视情况而定)访问:
Provider.of<A>(context) //This does not work. Why?
Provider.of<B>(context) //This works.
如何正确使用基类与Provider.ofie Provider.of<A>(context)?
编辑:ChangeNotifierProvider 仅适用于 B。我没有 A 的提供者。但是,我想使用 A 访问,因为 A 是 B 的基类。