我使用带有 flutter 的 cloud firestore 来存储聊天内容,并使用 where 条件来获取聊天内容。
文档正确返回,但添加新数据时聊天列表不会实时更新。
聊天记录如何存储:-
collection -> message {message、timestamp、sentBy、sentTo} 是消息字段
查询是
firestore
.collection('chats_v2')
.where('sentBy', isEqualTo: 'abc')
.where('sentTo', isEqualTo: 'xyz')
.orderBy('timestamp')
.snapshots();
聊天第一次加载完美,但是当新消息添加到收藏列表时不会更新
我也尝试过,这不起作用:
firestore
.collection('chats_v2')
.where('trackId', isEqualTo: trackId)
.where('groupId', isEqualTo: groupId)
.orderBy('timestamp')
.snapshots().listen((data){
//return the QuerySnapshot from here to StreamBuilder;
});
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)