这是错误信息
: The following NoSuchMethodError was thrown building Consumer<PageOffsetNotifier>(dirty,
: dependencies: [_InheritedProviderScope<PageOffsetNotifier>]):
: The method 'unary-' was called on null.
: Receiver: null
: Tried calling: unary-()
这是有消费者的课程
class LeopardImage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Consumer<PageOffsetNotifier>(
builder: (context,notifier,child) => Positioned(
width:300, left: -notifier.offset,
child: child,
),
child: Image.asset('assets/leopard.png'),
);
}
}
这里的PageOffsetNotifier是用ChangeNotifier扩展并传递给ChangeNotifierProvider的类
通知器将在将一页滑动到另一页时检测偏移值的变化并执行所需的功能.....
请告诉我我在消费者中遗漏了什么或做错了什么,因此,我收到了这个错误