4
votes

I am creating a flutter web app ,I want to connect my flutter web project with cloud firestore, is there any to connect my project to cloud firestore

I have try import cloud_firestore: ^0.12.5+2 in pubspec.yaml.

Because op depends on cloud_firestore >=0.3.0 which requires the Flutter SDK, version solving failed.

4

4 Answers

4
votes

The FlutterFire plugin that you found only targets iOS or Android.

If you're targeting the web, use the firebase-dart plugin.

Also see a similar answer I gave yesterday here: Is there a Dart interface to Firestore - with API as in https://firebase.google.com/docs/firestore/quickstart?

4
votes

You can now use official cloud_firestore plugin in flutter web, just follow the instructions in readme page to integrate plugin.

2
votes

You need to add the following dependency to your package manager:

cloud_firestore: 0.13.4

There are a couple of extra steps to take when configuring for web. These involve adding some script references to your index.html file with Google's SDK reserved URL's (this assumes you will be deploying to google hosting or at least serving locally for testing purposes).

<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>

I previously wrote a step by step guide to connecting a Flutter Web app to Google Cloud Firestore, including an example contact form.

Refs :

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

-1
votes

maybe you need add dependencies: firebase_web: ^5.0.9 to your pubspec.yaml. this page can help you https://pub.dev/packages/firebase_web