[英]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: 错误:无法以健全的空安全运行,因为以下依赖项不支持空安全:
For solutions, see https://dart.dev/go/unsound-null-safety有关解决方案,请参阅https://dart.dev/go/unsound-null-safety
There are many solutions for this problem.这个问题有很多解决方案。
environment
variable in pubspec.yaml
file to 2.10.0
pubspec.yaml
文件中的项目级environment
变量减少到2.10.0
environment:
sdk: ">=2.10.0 <3.0.0"
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"
Use dart migration tool in your package with dart migrate
command使用
dart migrate
命令在你的包中使用 dart 迁移工具
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.