You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

重装Android Studio后Flutter运行报错:Could not find an option named "no-sound-null-safety"

解决Flutter报错:Could not find an option named "no-sound-null-safety"

这个错误的核心原因是无空安全参数格式错误或运行配置写法不当,以下是具体修复步骤:

  • 检查运行命令的参数格式:
    正确启用无空安全的运行命令应为:

    flutter run --no-sound-null-safety
    

    注意参数前是两个短横线(--),如果你的命令里只写了no-sound-null-safety(无短横线)或单横线,就会触发该错误。

  • 修正Android Studio的运行配置:
    若通过IDE运行按钮启动应用:

    1. 点击顶部工具栏的运行配置下拉框,选择Edit Configurations...
    2. 在弹窗中找到你的Flutter应用配置
    3. 在Additional run args输入框中添加--no-sound-null-safety(确保是两个短横线开头)
    4. 点击Apply保存配置后重新运行应用
  • 排查配置文件中的错误:
    检查项目的pubspec.yaml、launch.json(若用VS Code)等配置文件,确认是否错误地将no-sound-null-safety作为独立选项写入,如有则删除或修正为正确参数格式。

  • 验证Flutter版本(可选):
    运行flutter --version查看当前版本,--no-sound-null-safety参数在Flutter 2.0及以上版本支持,若版本过旧,建议切换到稳定版并升级:

    flutter channel stable
    flutter upgrade
    

内容的提问来源于stack exchange,提问作者pranali kumbhar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 23:42:07