无法在Flutter中安装任何Firebase软件包

时间:2020-07-11 05:39:51

标签: firebase flutter firebase-realtime-database google-cloud-firestore flutter-dependencies

我正在使用VisualStudio作为IDE。 在添加cloud_firestore:^ 0.13.7作为依赖项并运行pub get时,出现以下错误:

[firebase] flutter pub get
Running "flutter pub get" in firebase...                        
Because cloud_firestore >=0.13.4 depends on cloud_firestore_web ^0.1.1 which depends on firebase ^7.0.0, cloud_firestore >=0.13.4 requires firebase ^7.0.0.

So, because firebase depends on cloud_firestore ^0.13.7 and firebase is 1.0.0+1, version solving failed.
pub get failed (1; So, because firebase depends on cloud_firestore ^0.13.7 and firebase is 1.0.0+1, version solving failed.)
exit code 1".

我的“ pubsec.yaml”文件如下:

name: firebase
description: A new Flutter project.
environment:
  sdk: ">=2.7.0 <3.0.0"
dependencies:
  flutter:
    sdk: flutter
  cloud_firestore: ^0.13.7
  cupertino_icons: ^0.1.3
dev_dependencies:
  flutter_test:
    sdk: flutter

请帮助。 谢谢。

2 个答案:

答案 0 :(得分:0)

由于兼容性原因,所有Firebase插件均进行了仔细的版本控制,因此,如果您的版本规范之一已关闭,则它将破坏依赖性。我也相信您缺少firebase_core依赖性。

请运行flutter clean并使用this page上给出的确切命令安装FlutterFire插件,然后使用flutter pub upgrade重新拉动所有内容。如果您还有其他问题,还有有关FlutterFire插件here的其他信息。

答案 1 :(得分:0)

您需要先安装firebase_core,然后才能在flutter应用程序中使用任何Firebase软件包。

请访问this link以查看文档。