一尘不染

Flutter网站:尝试调用非函数,例如null:'dart.global.firebase.storage

flutter

我将Firebase插件用于Web,并设法使用Firestore和身份验证。现在,我试图启用Firebase存储,但是当我实例化存储时,出现此错误

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

用于Firestore和身份验证,我使用:

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

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

用于存储:

fb.Storage storage = fb.storage();

阅读 353

收藏
2020-08-13

共1个答案

一尘不染

解决了!

index.html中 添加最新版本的Firebase存储:

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

yourClass.dart中

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

  fb.StorageReference _ref = fb.storage().ref('images');
2020-08-13