我在main方法中初始化firebase
void main(){
fb.initializeApp(
apiKey: "123",
authDomain: "123",
databaseURL: "123",
projectId: "123",
storageBucket: "123",
messagingSenderId: "123");
runApp(ng.AppComponentNgFactory, createInjector: injector);
}
然后在一个组件中,我导入firebase:
import 'package:firebase/firebase.dart' as fb;
最后我尝试使用存储:
fb.storage();
但是,我得到一个空指针:
EXCEPTION: NoSuchMethodError: tried to call a non-function, such as null: 'dart.global.firebase.storage'
STACKTRACE:
packages/firebase/src/top_level.ddc.js 64:100 storage
查看firebase dart包文档,如果要使用存储,则需要添加其他脚本。
见:https://pub.dartlang.org/documentation/firebase/latest/#do-you-need-to-use-firestore