M.Ali
M.Ali

Reputation: 10235

Flutter web: tried to call a non-function, such as null: 'dart.global.firebase.storage

Im using Firebase plugin for web and managed to work with firestore and authentication. Now, Im trying to enable firebase storage but when i instanciate Storage gives me this error

tried to call a non-function, such as null: 'dart.global.firebase.storage

for firestore and authentication I use :

import 'package:firebase/firebase.dart' as fb;
import 'package:firebase/firestore.dart';

 fb.Auth _firebaseAuth = fb.auth();
  Firestore _firestore =fb.firestore();

for Storage :

fb.Storage storage = fb.storage();

Upvotes: 12

Views: 7568

Answers (1)

M.Ali
M.Ali

Reputation: 10235

Solved!

In index.html add the latest version of firebase storage:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>

    <script src="https://www.gstatic.com/firebasejs/6.3.1/firebase-app.js"></script>
    <script src="https://www.gstatic.com/firebasejs/6.3.1/firebase-firestore.js"></script>
    <script src="https://www.gstatic.com/firebasejs/6.3.1/firebase-auth.js"></script>
    <script src="https://www.gstatic.com/firebasejs/6.3.1/firebase-storage.js"></script>
    <script defer src="main.dart.js" type="application/javascript"></script>
</head>
<body>
</body>
</html>

In yourClass.dart :

import 'package:firebase/firebase.dart' as fb;

  fb.StorageReference _ref = fb.storage().ref('images');

Upvotes: 30

Related Questions