Flutter Windows端升级cloud_firestore至4.13.0版本依赖冲突问题
解决Cloud Firestore v4.13+与Firebase Core Desktop的版本冲突问题
核心解决方案
移除firebase_core_desktop的直接依赖——最新版firebase_core已内置桌面平台支持,单独依赖该包会导致版本冲突。
操作步骤
- 编辑项目根目录下的
pubspec.yaml文件:- 删除
firebase_core_desktop: any这一行 - 将
firebase_core及其他Firebase依赖更新为与cloud_firestore兼容的版本,示例配置如下:firebase_core: ^2.24.2 firebase_analytics: ^10.8.0 firebase_auth: ^4.16.0 google_sign_in: any google_mobile_ads: any cloud_firestore: ^4.14.0
- 删除
- 执行依赖安装命令:
flutter pub get - 若缓存导致问题未解决,清除缓存后重新安装:
flutter pub cache clean flutter pub get
冲突原因说明
Cloud Firestore v4.10+要求firebase_core_platform_interface v5.0.0,但firebase_core_desktop最新稳定版(1.0.2)仅依赖firebase_core_platform_interface v4.5.0,二者依赖版本不兼容。同时,firebase_core从v2.10版本开始已原生支持Windows等桌面平台,无需再单独引入firebase_core_desktop,保留该依赖只会引发版本冲突。
内容的提问来源于stack exchange,提问作者Vandre
相关产品推荐
相关产品推荐

