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

Flutter升级后Chrome端启动报错:未找到‘FallThroughError’方法

解决Flutter Web启动时FallThroughError找不到的问题

问题背景

更新Flutter SDK及相关Firebase依赖后,在Chrome上启动项目时触发报错:

../../../.pub-cache/hosted/pub.dev/cloud_firestore_web-3.1.1/lib/src/utils/web_utils.dart:71:13: Error: Method not found: 'FallThroughError'.
throw FallThroughError();

当前依赖配置:

sdk: '>=3.0.0-35.0.dev <4.0.0'
cupertino_icons: ^1.0.5
firebase_core: ^2.4.0
cloud_firestore: ^4.2.0
firebase_auth: ^4.2.1

原因分析

FallThroughError在Dart 3.0及以上版本中已被移除,而你使用的cloud_firestore_web:3.1.1版本仍在调用这个已废弃的API,导致兼容性冲突。

解决方案

1. 升级Firebase依赖到适配Dart 3.0的版本

修改pubspec.yaml中的依赖配置,确保所有Firebase包都支持Dart 3.0:

sdk: '>=3.0.0 <4.0.0'
cupertino_icons: ^1.0.5
firebase_core: ^2.15.0
cloud_firestore: ^4.8.0
firebase_auth: ^4.10.0

2. 更新项目依赖

在项目根目录执行命令:

flutter pub get

3. 清理缓存(可选,若上述步骤无效)

如果更新后仍存在问题,清理Pub缓存后重新获取依赖:

flutter pub cache clean
flutter pub get

内容的提问来源于stack exchange,提问作者Byron Rodrigues

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.07 16:45:39