我将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();
答案 0 :(得分:0)
已解决!
在 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');