1 已在页面中进行了定义:
ShoppingCartCheckOutProvider shoppingCartCheckOutProvider;
2 已在页面中build函数中进行了赋值:
this.shoppingCartCheckOutProvider = Provider.of<ShoppingCartCheckOutProvider>(context);
程序运行时提示这个错误:
I/flutter ( 4223): Another exception was thrown: Error: Could not find the correct Provider<ShoppingCartCheckOutProvider> above this ShoppingCartPage2 Widget
原因:未全局定义声明
解决方法:在main.dart文件中做如下操作声明定义即可:
providers: [
....
ChangeNotifierProvider(builder: (_) => ShoppingCartCheckOutProvider()),
],