【发布时间】:2021-06-05 09:01:31
【问题描述】:
我是从 simone 的《flutter projects》一书中学习 Flutter(在 packt 上出版)。
我发现这段代码和书中的代码有点不同,因为现在一些关键字已经改变了(我猜)。
Future testData() async {
print('here'); // I can see this in debug
FirebaseFirestore db = FirebaseFirestore.instance; // book says Firestore instead of FirebaseFirestore
print('now here'); // but I can't see this , So, I think there is some issue with above lines.
var data = await db.collection('event_details').get(); // it has getDocuments()
var details = data.docs.toList(); //it has documents instead of docs
details.forEach((d) {
print(d.id); // it has documentID rather than just id
});
}
输出应该是类似于“nasfs3rasfsd...”的 ID
请帮助我哪里出错了。 并感谢您的帮助! ^^
【问题讨论】:
-
你能检查调试控制台吗?有什么错误吗?
-
不,实际上它必须打印在 firebase 网站上自动选择的 ID 或说文档 ID,你明白了吗,(是的,它打印空行而不是那个 ID,它没有'甚至不打印'现在在这里'行)。您需要屏幕截图或类似的东西吗?
标签: firebase flutter dart google-cloud-firestore