如何在 flutter for web 和 android 中使用 cloud_firestore?

How to use cloud_firestore in flutter for web and android?

我有一个 Flutter 应用程序,它按预期在 Android 上运行,但是如果我想为 Web 编译它,我会收到错误消息。

它必须与依赖项 cloud_firestore 做一些事情。如果我使用依赖项 firebase 它在网络上工作正常但在 android 现在不行..

这是我使用 cloud_firestore(为 web 编译)得到的错误消息:

Skipping compiling pay_balance|lib/main_web_entrypoint.dart with ddc because some of its
transitive libraries have sdk dependencies that not supported on this platform:

firebase_core|lib/firebase_core.dart

https://github.com/dart-lang/build/blob/master/docs/faq.md#how-can-i-resolve-skipped-compiling-warnings

有人可以帮助我吗?也许对 firestore 有另一个依赖(我没有找到其他在网络上工作的人 android)..

编辑:我已经在网络上使用了 firebase-dart 插件!! -> 仅适用于网络,但对我而言 android 无效 -> 我需要同时满足两者!!

或者有什么方法可以在导入时同时使用这两个包而不会出现网络编译错误cloud_firestore?

如果您想在 Web 和移动设备上使用 Firebase,您必须发挥创意。我创建了 fb_auth 插件,它在 iOS 和 Android 上使用移动 SDK firebase_auth,在网络上使用 firebase 包。这将为您提供一个用于身份验证的插件。

https://pub.dev/packages/fb_auth

我正在研究 firstore 和存储,但它们还没有准备好。

我还创建了一篇关于如何使用 flutter 执行此操作的文章:

https://medium.com/@rody.davis.jr/how-to-build-a-native-cross-platform-project-with-flutter-372b9e4b504f

你必须使用动态导入,这样在编译时它会摇晃它不需要的东西并且不会抛出错误。

目前这是在同一个项目中正式使用这两个插件的唯一方法。

编辑:cloud_firestore 现已添加

Web 现在支持两个 FutterFire 插件。 FlutterFire plugins supporting webfirebase_authfirebase_core

cloud_firestore 现在也支持