flutter 在运行老项目的时候,或者是添加一些第三方库的时候,会报
Cannot run with sound null safety, because the following dependencies don‘t support null safety;
报错是因为这些包不支持safety模式。
解决方法:
运行的时候添加–no-sound-null-safety
Android Studio工具
选择【Run】 -->【 Edit Configurations】 --> 【Add Additional Run args 】–> 【–no-sound-null-safety】,如下图:
VS
按图操作添加 --no-sound-null-safety
或者是命令行运行
$ flutter run --no-sound-null-safety
这样在dart 3.0以前就可以解决了
但是在3.0及以后,则会提示:
flutter --no-sound-null-safety pub get
Could not find an option named “no-sound-null-safety”.文章来源:https://www.toymoban.com/news/detail-656087.html
原因是从Dart 3.0开始,不支持无声音空安全。只能建议你尝试让你的代码更新到空安全;或者是将dart降级到3.0以前文章来源地址https://www.toymoban.com/news/detail-656087.html
到了这里,关于【Flutter】运行报错:Cannot run with sound null safety, because the following dependencies的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!