【发布时间】:2020-08-07 08:33:04
【问题描述】:
我想制作一个与 Cloud Firestore 和 Firebase 存储交互的 Dart 控制台应用。
我的第一个问题是:这可能吗?
我在网上搜索了几个小时以寻找示例,但我没有找到任何示例。我发现的只是这个example here,但我不明白它是如何工作的。我试过这段代码:
import 'package:firebase/firebase.dart';
import 'package:firebase/firestore.dart' as fs;
void main() {
initializeApp(
apiKey: "YourApiKey",
authDomain: "YourAuthDomain",
databaseURL: "YourDatabaseUrl",
projectId: "YourProjectId",
appId: "YourAppId",
storageBucket: "YourStorageBucket");
fs.Firestore store = firestore();
fs.CollectionReference ref = store.collection('myCollection');
ref.onSnapshot.listen((querySnapshot) {
print(querySnapshot);
});
}
第一件事是我不知道在哪里可以找到那些initializeApp 信息,例如YourApiKey、YourAuthDomain ...
第二件事是 VS 代码给了我这个警告
Omit type annotations for local variables.
【问题讨论】:
标签: firebase dart google-cloud-firestore firebase-storage