添加Firebase Remote Config后遇Firebase Storage平台兼容错误
Flutter添加Firebase Remote Config时出现
dart:html平台不兼容错误 为Flutter项目集成Firebase Remote Config时触发如下错误:
Firebase Storage: Dart library 'dart:html' is not available on this platform
项目依赖列表
cupertino_icons: ^1.0.2 tuple: ^2.0.1 http: ^0.13.6 firebase: ^9.0.3 provider: ^6.0.5 google_sign_in: ^6.1.6 firebase_core: ^2.11.0 image_picker: ^0.8.7+4 file_picker: ^5.3.0 syncfusion_flutter_pdf: ^21.2.4 path: ^1.8.2 shared_preferences: ^2.1.1 universal_io: ^2.2.0 flutter_dotenv: ^5.0.2 flutter_timer_countdown: ^1.0.5 rive: ^0.11.4 path_provider: ^2.1.1 flutter_email_sender: ^6.0.1 csv: ^5.0.2 logging_flutter: ^3.0.0 logging: ^1.2.0 permission_handler: ^11.0.0 mockito: ^5.4.2 fl_chart: ^0.64.0 intl: ^0.18.1 rxdart: ^0.27.7 introduction_screen: ^3.1.12 fluttertoast: ^8.2.4 flutter_svg: ^2.0.9 dropdown_search: ^5.0.6 percent_indicator: ^4.2.3 animated_button: ^0.2.0 animated_radio_buttons: ^1.0.0 matertino_radio: ^1.0.4 flutter_launcher_icons: ^0.13.1 adapty_flutter: ^2.7.1 adapty_ui_flutter: ^2.0.5 multi_dropdown: ^2.0.0 choice: ^2.3.0 quiver: ^3.2.1 lottie: ^2.7.0 vibration: ^1.8.4 collection: ^1.17.2 flutter_native_splash: ^2.3.7 url_launcher: ^6.2.4 tutorial_coach_mark: ^1.2.11 selectable: ^0.3.0 animated_item_picker: ^2.0.0 flutter_ioc_container: ^1.0.12 ioc_container: ^1.0.12 sign_in_with_apple: ^5.0.0 firebase_analytics: ^10.10.1 flutter_getit: ^2.0.0 get_it: ^7.6.9 mocktail: ^1.0.3 firebase_auth: ^4.19.1 timeago: ^3.6.1 firebase_storage: ^11.7.2 cloud_firestore: ^4.17.0 loggy: ^2.0.3 animated_bottom_navigation_bar: ^1.3.3 cloud_functions: ^4.7.3 youtube_player_flutter: ^9.0.1 flutter_animate: ^4.5.0 firebase_app_check: ^0.2.2+5 firebase_remote_config: ^4.4.6
已尝试的解决方法
- 移除Firebase Remote Config或重装Firebase Storage均无效
- 删除
AppData/Local/Pub/Cache目录 - 删除
./dart-tools/flutter_build/<hash>目录 - 删除
./build/<hash>目录 - 执行
flutter clean; flutter pub get命令
补充:上述两个哈希目录总是生成相同哈希值,错误日志显示调用栈指向依赖链中的dart:html引用问题。
解决方案
- 移除冲突依赖:删除pubspec.yaml中的
firebase: ^9.0.3。这个是旧版纯Dart Firebase SDK,和你正在使用的官方Flutter Firebase插件(如firebase_core、firebase_storage等)存在兼容性冲突,旧包依赖仅Web平台支持的dart:html库,导致移动端编译失败。 - 清理并重新获取依赖:执行以下命令
flutter clean && flutter pub get - 验证依赖链:运行
flutter pub deps检查输出,确认没有再出现依赖dart:html的包。 - 重新编译项目:尝试运行或编译项目,错误应该会消失。
内容的提问来源于stack exchange,提问作者KSHMR
相关产品推荐
相关产品推荐

