【问题标题】:How to use cloud firestore in Flutter web app如何在 Flutter Web 应用中使用 Cloud Firestore
【发布时间】:2019-12-01 17:33:36
【问题描述】:

我正在创建一个 Flutter Web 应用程序,我想将我的 Flutter Web 项目与 Cloud Firestore 连接,有没有可以将我的项目连接到 Cloud Firestore 的方法

我已经尝试在 pubspec.yaml 中导入 cloud_firestore: ^0.12.5+2。

由于op依赖cloud_firestore >=0.3.0,需要Flutter SDK,版本解析失败。

【问题讨论】:

    标签: google-cloud-firestore flutter-web


    【解决方案1】:

    您现在可以在flutter web中使用官方的cloud_firestore插件,只需按照自述页面中的说明集成插件即可。

    【讨论】:

      【解决方案2】:

      您发现的 FlutterFire plugin 仅针对 iOS 或 Android。

      如果您的目标是网络,请使用firebase-dart plugin

      还可以在这里看到我昨天给出的类似答案:Is there a Dart interface to Firestore - with API as in https://firebase.google.com/docs/firestore/quickstart?

      【讨论】:

      • 非常感谢,请问我可以知道如何在flutter web中配置firebase_dart插件吗?
      【解决方案3】:

      您需要将以下依赖项添加到您的包管理器中:

      cloud_firestore: 0.13.4
      

      在为 Web 配置时需要执行几个额外的步骤。这些包括使用Google's SDK reserved URL's 将一些脚本引用添加到您的 index.html 文件(这假设您将部署到 google 托管或至少在本地提供服务以进行测试)。

      <script src="/__/firebase/7.9.2/firebase-app.js"></script>
      <script src="/__/firebase/7.9.2/firebase-auth.js"></script>
      <script src="/__/firebase/7.9.2/firebase-firestore.js"></script
      <script src="/__/firebase/init.js"></script>
      

      我之前为connecting a Flutter Web app to Google Cloud Firestore 写了一个分步指南,包括一个示例联系表。

      参考:

      https://medium.com/@mat_wright/connecting-a-flutter-web-form-to-google-cloud-firestore-f6bf7aa28f99

      https://firebase.google.com/docs/hosting/reserved-urls

      enter link description here

      【讨论】:

      • 您的“分步指南”位于付费墙后面。请更新不需要订阅的指南链接。
      • @malwr 谢谢。我不清楚某些代码是如何添加的,您的 Github 上是否有指向您的 .dart 文件/的链接?
      【解决方案4】:

      也许你需要添加 依赖项: firebase_web:^5.0.9 到您的 pubspec.yaml。 这个页面可以帮助你https://pub.dev/packages/firebase_web

      【讨论】:

        猜你喜欢
        • 2020-04-26
        • 2020-03-27
        • 2020-03-12
        • 1970-01-01
        • 1970-01-01
        • 2020-09-21
        • 2022-01-23
        • 2019-05-26
        • 2020-09-08
        相关资源
        最近更新 更多