[英]"flutter run" gives me a lot of errors while everything works perfect using "flutter run --no-sound-null-safety"
I have been making this app for a while now, and I have always used flutter run --no-sound-null-safety
to run the app.我制作这个应用程序已经有一段时间了,我一直使用flutter run --no-sound-null-safety
来运行这个应用程序。 Everything went well.一切顺利。 But now I try to run the project with the command flutter run
and I get a lot of errors.但是现在我尝试使用命令flutter run
来运行该项目,但出现了很多错误。 Errors I wouldn't have gotten when using flutter run --no-sound-null-safety
.使用flutter run --no-sound-null-safety
时我不会遇到错误。
flutter run
使用flutter run
时Think of errors like type type 'Null' is not a subtype of type 'bool'
or The relevant error-causing widget was: Consumer<ConnectivityProvider>
and Unhandled Exception: type 'Null' is not a subtype of type 'int'
.想想像 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'
错误。
Even when I made no changes in the code.即使我没有对代码进行任何更改。 How is this possible and what should I do to fix these errors?这怎么可能,我应该怎么做才能解决这些错误?
You get these errors because your code is not sound null safe.你得到这些错误是因为你的代码不安全 null 。 If you for example initialize例如,如果您初始化
bool x = null;
you will get an error because null safety tries to avoid errors related to variables that are not initialized.你会得到一个错误,因为 null 安全试图避免与未初始化的变量相关的错误。 This can help you to make your code null safe.这可以帮助您确保代码 null 的安全。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.