简体   繁体   English

“flutter run”给了我很多错误,而使用“flutter run --no-sound-null-safety”一切正常

[英]"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时我不会遇到错误。

When using 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.

相关问题 使用 --no-sound-null-safety 运行单元测试 - Run unit tests while using --no-sound-null-safety 如何在 vscode(Flutter)的单次运行/调试中添加 --no-sound-null-safety? - How to add --no-sound-null-safety on a single run/debug on vscode (Flutter)? 使用 --no-sound-null-safety Flutter 生成 App Bundle - Generate App Bundle with --no-sound-null-safety Flutter 无法正常运行 null 安全,Flutter - Cannot run with sound null safety, Flutter “无法以声音 null 安全运行”尝试将 Google 地图与 Flutter 一起使用 - "Cannot run with sound null safety" trying to use Google Maps with Flutter “无法正常运行 null 安全” Flutter 现有项目? - "Cannot run with sound null safety" Flutter an existing Project? 错误:无法以健全的 null 安全运行,因为以下依赖项不支持 null 安全; 在 flutter - Error: Cannot run with sound null safety, because the following dependencies don't support null safety; in flutter Flutter 不能以空安全运行,因为以下依赖不支持空安全 - Flutter Cannot run with sound null safety, because the following dependencies don't support null safety 无法正常运行 null 安全,因为以下依赖项 [build\windows\flutter\flutter_assemble.vcxproj] - Cannot run with sound null safety, because the following dependencies [build\windows\flutter\flutter_assemble.vcxproj] Flutter 应用程序在使用 flutter build apk --split-per-abi --no-sound-null-safety 构建后未从 REST API 获取任何数据 - Flutter app not fetching any data from REST API after building it with flutter build apk --split-per-abi --no-sound-null-safety
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM