Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flutter web TypeError: dart.global.firebase.storage is not a function

I am building a web app in flutter trying to add photos to firebase storage.

I am having this error and most post say its solve by adding

https://www.gstatic.com/firebasejs/8.2.4/firebase-database.js"

but I have it

What else could be causing the TypeError: dart.global.firebase.storage is not a function

<body>
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/8.2.4/firebase-app.js"></script>

<!-- TODO: Add SDKs for Firebase products that you want to use
     https://firebase.google.com/docs/web/setup#available-libraries -->
<script src="https://www.gstatic.com/firebasejs/8.2.4/firebase-analytics.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.4/firebase-firestore.js"></script>


<script>
  // Your web app's Firebase configuration
  // For Firebase JS SDK v7.20.0 and later, measurementId is optional
  var firebaseConfig = {
    apiKey: "",
    authDomain: "",
    databaseURL: "",
    projectId: "",
    storageBucket: "",
    messagingSenderId: "",
    appId: "",
    measurementId: ""
  };
  // Initialize Firebase
  firebase.initializeApp(firebaseConfig);
  firebase.analytics();
</script>
</script>
like image 542
bay Avatar asked Jan 25 '21 21:01

bay


People also ask

How do I use firebase with flutterfire?

Before using FlutterFire on the web, you must first import the Firebase JavaScript SDK and initialize Firebase. The only way to currently add the Firebase SDKs to your Flutter web project is by importing the scripts from the Firebase content delivery network (CDN). Add the firebase-app.js script to your index.html file: ...

Why is Firebase-FireStore not working?

Not only the ones in the example. If you did it, and it is still not working it is because you need to add the CDN for the other services you are using. In my case they were firebase-auth.js and firebase-firestore.js.

Why is my CDN not working with Firebase?

You have to add ALL the CDN's you need from Firebase. Not only the ones in the example. If you did it, and it is still not working it is because you need to add the CDN for the other services you are using. In my case they were firebase-auth.js and firebase-firestore.js.

Where can I find the latest information on Firebase SDK?

You can find the latest information on firebase.google.com: Before using FlutterFire on the web, you must first import the Firebase JavaScript SDK and initialize Firebase. The only way to currently add the Firebase SDKs to your Flutter web project is by importing the scripts from the Firebase content delivery network (CDN).


1 Answers

I had the same issue and fixed it by adding the another script for firebase-storage

...
<script src="https://www.gstatic.com/firebasejs/8.2.4/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.4/firebase-storage.js"></script>
...
like image 132
Callum Avatar answered Sep 27 '22 20:09

Callum