由于依赖项不支持空安全

由于依赖项不支持空安全

本文介绍了由于依赖项不支持空安全,因此无法以健全的空安全运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我关注了启用空安全"在 dart.dev迁移strong> 我的整个 Flutter 应用程序都具有零安全性.

I have followed "Enabling null safety" on dart.dev and also migrated my whole Flutter app to null safety.

现在,我正在尝试使用 flutter run 运行它,但是由于以下错误,它无法启动:

Now, I am trying to run it using flutter run, however, it will not start because of the following error:

Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:

 - package:cloud_firestore_web
 - package:firebase_core_web
 - package:shared_preferences
 - package:url_launcher_web
 - package:firebase_auth
 - package:http
 - package:provider
...

For solutions, see https://dart.dev/go/unsound-null-safety
Failed to compile application.

URL 上的指南说我应该"在迁移之前等待依赖项迁移包",但我现在想使用 NNBD.

The guide at the URL says that I should "wait for dependencies to migrate before you migrate your package", but I want to use NNBD now.

我该怎么做?

推荐答案

首先,您应该通读 了解不健全的空安全.
如果您确定要以不健全的空安全性运行您的应用程序,您可以使用以下命令:

First, you should read through the guide to understand unsound null safety.
If you are sure that you want to run your app with unsound null safety, you can use the following command:

flutter run --no-sound-null-safety

--no-sound-null-safety 选项没有记录在文章中,但是,我在过去几个月没有遇到任何问题(尤其是自从整个Flutter 框架已经迁移到空安全).

The --no-sound-null-safety option is not documented in the article, however, I have not experienced any problems with it for the last few months (and especially not since the whole Flutter framework has been migrated to null safety).

编辑:文档现已更新以包含此内容.请参阅测试或运行混合版本程序.

Edit: the documentation has now been updated to include this. See Testing or running mixed-version programs.

要在您选择的 IDE 中进行设置,您可以使用:

To set this up in your IDE of choice, you can use:

  • IntelliJ/Android Studio 中:编辑配置"(在您的运行配置中)→附加运行参数".
  • VS Code 中:搜索Flutter run additional args";在您的用户设置中.
  • In IntelliJ/Android Studio: "Edit Configurations" (in your run configurations) → "Additional run args".
  • In VS Code: search for "Flutter run additional args" in your user settings.

在这两种情况下,添加--no-sound-null-safety.

In both cases, add --no-sound-null-safety.

对于测试,你会想要做同样的事情:

For tests, you will want to do the same thing:

  • IntelliJ/Android Studio 中:编辑配置"(在您的运行配置中)→附加参数".
  • VS Code 中:搜索Flutter test additional args";在您的用户设置中.
  • In IntelliJ/Android Studio: "Edit Configurations" (in your run configurations) → "Additional args".
  • In VS Code: search for "Flutter test additional args" in your user settings.

在这两种情况下,添加--no-sound-null-safety.

In both cases, add --no-sound-null-safety.

这篇关于由于依赖项不支持空安全,因此无法以健全的空安全运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 21:13