【发布时间】:2023-03-30 03:40:01
【问题描述】:
我是新来的颤振。我想使用它的uid从firestore获取一个特定的文档,然后以我可以处理的值类型传输这个文档。但是当我运行我的应用程序时,我得到了一个断点:StateError(错误状态:DocumentSnapshotPlatform 中不存在字段)。 这是代码:
final cloth = await DatabaseService(uid: uid)
.clothCollection
.doc(uid)
.get()
.then((doc) => {
Cloth(
brand: doc.get('brand'),
name: doc.get('name'),
color: doc.get('color'),
url: doc.get('url'))
});
和布:
class Cloth {
final String? name;
final String? url;
final String? brand;
final String? color;
Cloth({this.name, this.brand, this.color, this.url});
}
如果有更简单的方法来获取此文档,请告诉我。感谢您的帮助!
【问题讨论】:
-
可能是 doc 没有 .get() 函数。
标签: firebase flutter dart google-cloud-firestore