How to use cloud_firestore in flutter for web and android?

前端 未结 2 2001
情歌与酒
情歌与酒 2021-02-15 17:42

I have a Flutter app which works on Android as expected but if I want to compile it for Web I get an error.

It has to do something with the dependency cloud_firestore. I

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-15 18:34

    If you want to use Firebase on Web and Mobile you have to get creative. I created the fb_auth plugin that uses the Mobile SDK firebase_auth on iOS and Android and the firebase package on web. This will give you a single plugin for auth.

    https://pub.dev/packages/fb_auth

    Im working on firstore and storage but they are not ready yet.

    I have also created an article on how to do this with flutter:

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

    You have to use dynamic imports so that at compile time it tree shakes what it doesn't need and will not throw an error.

    Currently this is the only way to officially use both plugins in the same project.

提交回复
热议问题