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

Flutter旧项目Firebase报错:ActionCodeInfo未定义FallThroughError方法如何解决?

解决Flutter旧项目Firebase的FallThroughError报错问题

报错核心原因是firebase_auth_platform_interface-6.10.1版本的代码中使用了Dart高版本已移除的FallThroughError类,而项目Dart SDK版本较高导致冲突。以下是具体解决办法:

  • 调整Dart SDK版本适配旧依赖
    打开项目根目录的pubspec.yaml,在environment字段指定兼容该依赖的Dart版本范围,比如:

    environment:
      sdk: '>=2.12.0 <3.0.0'
    

    保存后执行flutter pub get重新拉取依赖。

  • 修改缓存中依赖源码(临时应急方案)
    找到报错文件路径C:/Users/Rohit/AppData/Local/Pub/Cache/hosted/pub.dev/firebase_auth_platform_interface-6.10.1/lib/src/action_code_info.dart,定位到抛出FallThroughError()的代码段,替换为Dart高版本兼容的错误抛出方式,比如:

    // 原代码:throw FallThroughError();
    throw UnsupportedError('Unsupported action code info type');
    

    保存后重启项目即可生效。

  • 强制升级Firebase Auth依赖到兼容版本
    在pubspec.yaml中更新firebase_auth到最新稳定版本,比如:

    dependencies:
      firebase_auth: ^4.15.0
    

    执行命令强制升级主版本:

    flutter pub upgrade --major-versions firebase_auth
    

    若出现其他Firebase相关依赖冲突,同步调整其他Firebase包(如firebase_core)的版本保持一致。

  • 彻底清除缓存后重新获取依赖
    执行以下命令清空Flutter缓存和Pub缓存,避免残留旧代码干扰:

    flutter clean
    flutter pub cache clean
    flutter pub get
    

内容的提问来源于stack exchange,提问作者Rohit Balage

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.23 19:12:12