简体   繁体   English

由于自定义依赖项不支持健全的空安全性,无法构建 dart 项目

[英]Cannot build dart project due to custom dependencies doesn't support sound null safety

I have been studying over dart projects and tesing dart packages and interdependencies.我一直在研究 dart 项目并测试 dart 包和相互依赖关系。 I created a Dart Project called console_full_project, where within the project i made a package called calculator and added it to main projects pubspec.yaml file.我创建了一个名为 console_full_project 的 Dart 项目,在项目中我创建了一个名为calculator 的包并将其添加到主项目的 pubspec.yaml 文件中。

main project's pubspec.yaml codes are主要项目的 pubspec.yaml 代码是

name: console_full_project
description: A sample command-line application.
version: 1.0.0

publish_to: none

# homepage: https://www.example.com

environment:
  sdk: ">=2.17.0-266.8.beta <3.0.0"

dependencies:
  calculator:
    path: "packages/calculator"

dev_dependencies:
  lints: ^2.0.0
  test: ^1.16.0

and my packages pubspec.yaml file's codes are我的包 pubspec.yaml 文件的代码是

name: calculator

environment:
  sdk: ">=2.10.0<3.0.0"

dependencies:
  lints: ^2.0.0

While a tried dart run command in my terminal虽然在我的终端中尝试过dart run命令

It resulted结果

Failed to build console_full_project:console_full_project: Error: Cannot run with sound null safety, because the following dependencies don't support null safety:无法构建console_full_project:console_full_project: 错误:无法以健全的空安全运行,因为以下依赖项不支持空安全:

  • package:calculator包:计算器

For solutions, see https://dart.dev/go/unsound-null-safety有关解决方案,请参阅https://dart.dev/go/unsound-null-safety

There are many solutions for this problem.这个问题有很多解决方案。

  1. Decrease project level environment variable in pubspec.yaml file to 2.10.0pubspec.yaml文件中的项目级environment变量减少到2.10.0
environment:
  sdk: ">=2.10.0 <3.0.0"
  1. Increase package level environment variable in pubspec.yaml file to 2.12.0 or abovepubspec.yaml文件中的包级别environment变量增加到2.12.0或更高版本
environment:
  sdk: ">=2.12.0 <3.0.0"
  1. Use dart migration tool in your package with dart migrate command使用dart migrate命令在你的包中使用 dart 迁移工具

  2. It might also work.它也可能有效。 Try to run the project with the following command尝试使用以下命令运行项目

flutter run --no-sound-null-safety

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法以健全的 null 安全运行,因为以下依赖项不支持 null 安全 - Cannot run with sound null safety, because the following dependencies don't support null safety 错误:无法以健全的 null 安全运行,因为以下依赖项不支持 null 安全; 在 flutter - Error: Cannot run with sound null safety, because the following dependencies don't support null safety; in flutter 无法以声音 null 安全运行,因为依赖项不支持 null 安全 - Cannot run with sound null safety because dependencies don't support null safety Flutter 不能以空安全运行,因为以下依赖不支持空安全 - Flutter Cannot run with sound null safety, because the following dependencies don't support null safety "无法以可靠的 null 安全性运行,因为以下依赖项不支持 null 安全性:" - Cannot run with sound null safety, because the following dependencies don't support null safety: 错误:无法以健全的 null 安全运行,因为以下依赖项不支持 null 安全: - Error: Cannot run with sound null safety, because the following dependencies don't support null safety: 无法以声音 null 安全运行,因为依赖项不支持 null 安全 - Cannot run with sound null safety because dependencies doesnot 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] “无法正常运行 null 安全” Flutter 现有项目? - "Cannot run with sound null safety" Flutter an existing Project? Flutter 2.0 以下依赖不支持 null 安全 - Flutter 2.0 following dependencies don't support null safety
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM