[英]"flutter run" gives me a lot of errors while everything works perfect using "flutter run --no-sound-null-safety"
我制作这个应用程序已经有一段时间了,我一直使用flutter run --no-sound-null-safety
来运行这个应用程序。 一切顺利。 但是现在我尝试使用命令flutter run
来运行该项目,但出现了很多错误。 使用flutter run --no-sound-null-safety
时我不会遇到错误。
flutter run
时想想像 type type 'Null' is not a subtype of type 'bool'
或The relevant error-causing widget was: Consumer<ConnectivityProvider>
and Unhandled Exception: type 'Null' is not a subtype of type 'int'
错误。
即使我没有对代码进行任何更改。 这怎么可能,我应该怎么做才能解决这些错误?
你得到这些错误是因为你的代码不安全 null 。 例如,如果您初始化
bool x = null;
你会得到一个错误,因为 null 安全试图避免与未初始化的变量相关的错误。 这可以帮助您确保代码 null 的安全。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.