【发布时间】:2019-09-24 20:02:46
【问题描述】:
我有一个集合'posts',其中包含作为特定用户的uid的文档,在每个文档下我都有一个包含字符串'likes'的数组'posts'和一个再次包含字符串'userpost'的地图'post' .
我需要在我的主页中将“用户帖子”的数据显示为列表。有人可以建议我对此进行查询。
我试过这个:
return Firestore.instance.collection('posts').where('posts', arrayContains: 'post').snapshot();
在我的主页 listview.builder 下,我正在检索这样的数据:-
Text( snapshot.data.documents[i].data['userpost'], )
但是运行后首页什么都没有显示,并抛出一个execption:A build function returned null。
【问题讨论】:
-
为快照添加等待,将其存储在变量中并首先执行console.log以查看您是否正在获取数据。不要忘记使用 .val()
标签: firebase flutter nosql google-cloud-firestore