📌  相关文章
📜  在 .initState() 完成之前调用了dependOnInheritedWidgetOfExactType<_InheritedProviderScope<>>() 或dependOnInheritedElement(). - 无论代码示例

📅  最后修改于: 2022-03-11 14:58:18.937000             🧑  作者: Mango

代码示例1
Issue is Provider.of(context) is supposed to be used inside the widget tree, 
and anything that is outside of the build() method, is not in the widget tree.
But if you still want to use it, then you need to set the listen parameter to 
false.

Example:
@override
void initState() {
  final _searchProvider = Provider.of(context, listen: false);
  super.initState();
}