【问题标题】:Error: Cannot run with sound null safety, because the following dependencies don't support null safety错误:无法以可靠的 null 安全运行,因为以下依赖项不支持 null 安全
【发布时间】:2021-10-23 22:27:57
【问题描述】:

希望你一切顺利!!

我目前正在开发用于机器人控制的控制板面板 我正在为颤动的移动部分工作,所以我遇到了这个错误:

错误:无法以可靠的 null 安全性运行,因为以下依赖项 不支持空安全:

  • package:control_pad

有关解决方案,请参阅https://dart.dev/go/unsound-null-safety lib/main.dart:77:5:警告:null-aware 操作的操作数 '?.'具有类型“StreamSubscription”w 不包括 null。

  • “StreamSubscription”来自“dart:async”。
  • 'ScanResult' 来自'package:flutter_blue/flutter_blue.dart' ('../../AppData/Local/Pub/Cache/hosted/pub.d

FAILURE:构建失败并出现异常。 flutter error screenshot

我真的需要你的帮助

谢谢!

【问题讨论】:

  • 这个错误有数百种解决方案。为什么不按照错误信息的指示先访问dart.dev/go/unsound-null-safety
  • 是的,我访问过它并尝试了官方网站的一些解决方案,但不幸的是我仍然遇到同样的错误

标签: flutter dart mobile flutter-test flutter-plugin


【解决方案1】:

在 Android Studio 上试试这个解决方案

  1. 开始运行-> 编辑配置。
  2. 将此行添加到 额外的运行参数

--no-sound-null-safety

  1. 申请
  2. 好的

enter image description here

【讨论】:

    【解决方案2】:

    要使用 --no-sound-null-safety 运行您的项目,请将此行添加到您的 main.dart 文件的顶部(第一行)并带有注释..

    // @dart=2.9

    然后运行你的项目。

    阅读更多:Reference

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-25
      • 2021-03-03
      • 2021-09-02
      • 2021-09-29
      • 2021-06-04
      • 2021-09-18
      • 2021-11-19
      相关资源
      最近更新 更多