构建 MyApp(脏,状态:_MyAppState#86032)抛出了以下 NoSuchMethodError:
The following NoSuchMethodError was thrown building MyApp(dirty, state: _MyAppState#86032):
我收到此错误消息,但不知道如何解决:
Exception caught by widgets library
The following NoSuchMethodError was thrown building MyApp(dirty, state: _MyAppState#86032):
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 时发生了这种情况,但那没有用。
听起来您可能已将 flutter 更新到具有空安全性的版本。
发生这种情况时,methods 不能为 null,即使在以前版本的 flutter 中是可以的 运行。
看看这些参考资料:
Null Safety
我收到此错误消息,但不知道如何解决:
Exception caught by widgets library The following NoSuchMethodError was thrown building MyApp(dirty, state: _MyAppState#86032):
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 时发生了这种情况,但那没有用。
听起来您可能已将 flutter 更新到具有空安全性的版本。 发生这种情况时,methods 不能为 null,即使在以前版本的 flutter 中是可以的 运行。 看看这些参考资料: Null Safety