【发布时间】:2022-01-24 15:26:56
【问题描述】:
我收到此错误消息,但不知道如何解决它:
小部件库捕获的异常 在构建 MyApp(dirty, state: _MyAppState#86032) 时引发了以下 NoSuchMethodError:
The method 'call' was called on null.
Receiver: null
Tried calling: call(Instance of 'ChangeNotifierProvider<UserLoggedIn>')```
这是导致此问题的代码:
void main() {
runApp(ProviderScope(child:MyApp()));
}
class MyApp extends StatefulHookWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp>
我认为我应该更改当前使用的 Flutter 版本,因为这发生在我更新 Flutter 时,但没有奏效。
【问题讨论】:
-
是否通过将
MyApp设置为 statelessWidget 或 statefulWidget 来实现? -
嘿Yeasin,我的问题仍然存在。它发生在 statefulWidget。
标签: flutter dart dart-null-safety