8
votes

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. If I use the dependency firebase it works fine on the web but on android now not..

This is the error message I get using cloud_firestore (compiling for 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

Can anybody help me? Maybe with another dependency for firestore (I did not find others which are working on web and android)..

Edit: I have used the firebase-dart plugin for web!! -> Only works on the web but not in android for me -> I need something for both at the same time!!

Or is there a Way I can use both packages without getting a compling error for the web when I import cloud_firestore?

2
@Frank van Puffelen my Question did not get answered by that... I had used the dependency fiebase before -> then I only got it to work on the Web but NOT in Android at the same time as I said in my Post.Maxi
The Flutter/Dart plugins from Firebase for Web and Android/iOS are not compatible with each other. Maybe the Flutter build system allows conditional compilation?Frank van Puffelen

2 Answers

4
votes

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.

2
votes

EDIT: cloud_firestore now added

Two of the FutterFire plugins are now supported for web. FlutterFire plugins supporting web firebase_auth and firebase_core

cloud_firestore is now also supported