12

我使用 Firebase 网络插件并设法使用 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();
4

1 回答 1

30

解决了!

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');
于 2019-07-28T18:57:44.643 回答