firebase_messaging与项目的依赖一致性

firebase_messaging dependecy consistency with the project

我有一些问题,我很想得到答案,因为这是我第一次使用 Flutter 和 Google 服务进行开发。

所以我一直在关注 Udemy 的课程,它创建于 2020 年,但从未更新过,现在在开发了一半的项目后,我遇到了 Firebase Messaging 的问题,在课程中使用的版本是7.0.3,现在最新的版本是9.1.4,变化很大。

我尝试安装了 7.0.3 版本,但没有成功! 您能提出任何解决方案吗,因为正如我所说,我是初学者,即使遵循了一些文档,我也发现自己被卡住了,在此先感谢您。

看起来您的依赖项不兼容。 要解决这个问题,您需要使用 firebase_corefirebase_messaging.

的兼容版本

你的firebase_core版本是1.1.0对应的firebase_messaging版本是9.1.3如下图,所以你应该使用9.1.3来消除错误.

    // pubspec.yaml of the firebase_messaging plugin

    name: firebase_messaging
    // ...
    repository: https://github.com/FirebaseExtended/flutterfire/tree/master/packages/firebase_messaging/firebase_messaging
    version: 9.1.3
    
    // ...
    
    dependencies:
      firebase_core: ^1.1.0
   
    //...

Source