【发布时间】:2019-07-26 07:06:00
【问题描述】:
我需要获取快照元数据,以便检查写入 Firestore 是否成功。我查看source,发现有SnapshotMetadata 和布尔值hasPendingWrites()。但是没有示例如何实现,我在任何地方都找不到。
我需要实现,以便可以在我的聊天应用程序中显示消息是否已发送或仍在发送。
我的代码:
child: new FirestoreAnimatedList(
query: Firestore.instance.collection('Collection')
.orderBy('timestamp', descending: true)
.snapshots(),
padding: new EdgeInsets.all(8.0),
reverse: true,
itemBuilder: (_, DocumentSnapshot snapshot,
Animation<double> animation, int x) {
return new Chat(
snapshot: snapshot, animation: animation);
},
),
我找不到如何在query 中获取SnapshotMetadata 并输入itemBuilder,因此如果发送,我可以显示progressIndicator。
有人知道解决办法吗?
谢谢!
【问题讨论】:
-
Flutter 可能只是在现有方案的顶部有一个包装器来请求元数据更新。 firebase.google.com/docs/firestore/query-data/…
-
@DougStevenson 感谢您的链接!但 doc 示例仅使用
.onSnapshot/.addSnapshotListener指定includeMetadataChanges: true。在我的问题中查询上述QuerySnapshot时,我需要确保获得元数据。我将query用于stream而不是addSnapshotListener。
标签: firebase dart flutter nosql google-cloud-firestore