Mohamed Hussien
Mohamed Hussien

Reputation: 17

Flutter web Firebase Firestore

I am trying to connect Firestore to my web project but it gives me "no firebase app has been created" this is the way I used the script in the index file

<script src="https://www.gstatic.com/firebasejs/9.6.8/firebase-app.js"></script>
  <script src="https://www.gstatic.com/firebasejs/9.6.8/firebase-firestore.js"></script>
  <script>
    var firebaseConfig = {
    apiKey: "-------cnto--------------",
    authDomain: "---------.firebaseapp.com",
    projectId: "---------",
    storageBucket: "---------.appspot.com",
    messagingSenderId: "---------48",
    appId: "1:---------48:web:---------89"
  };

  firebase.initializeApp(firebaseConfig);
  </script>

and this is the way I initialize the app

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(MyApp());

}

when I added await and async it waits forever and gives me a white screen like there is nothing to wait for

Upvotes: 0

Views: 610

Answers (1)

Code on the Rocks
Code on the Rocks

Reputation: 17566

Setup the FlutterFire CLI and then run this in your terminal:

flutterfire configure

This tool is awesome and it makes it so you never have to touch native files again when setting up Firebase.

Upvotes: 2

Related Questions