简体   繁体   English

在颤振中提供程序包有问题

[英]Having Problem in provider package in flutter

This is the error showing Error is showing这是错误显示错误显示

And this is the code flutter provider这是代码颤振提供者

how to solve this如何解决这个问题

As the error message explains, in order to call Provider.of, you need to actually have a provider widget as an ancestor in that context.正如错误消息所解释的那样,为了调用 Provider.of,您实际上需要一个提供程序小部件作为该上下文中的祖先。 When you declare your provider widget, you need to declare the "create" field so that what is being provided is actually instantiated and associated with that context.当您声明您的提供程序小部件时,您需要声明“创建”字段,以便提供的内容实际实例化并与该上下文相关联。

More info is under "usage" here:更多信息在“使用”下:

https://pub.dev/packages/provider https://pub.dev/packages/provider

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM