我正在获取20条评论的价值,但我只在我的帖子上输入了两条评论,我还没有完成这个解决方案。在上面的代码中,我使用的是流生成器,错误的地方就是我把查询放在我的文本上。
流生成器:
StreamBuilder(
stream: FirebaseFirestore.instance.collection("post").snapshots(),
builder: (BuildContext context,AsyncSnapshot<QuerySnapshot>snapshot){
return ListView.builder(
shrinkWrap: true,
scrollDirection: Axis.vertical,
itemCount: snapshot.data.docs.length,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (_,index) {
return
Text('${FirebaseFirestore.instance.collection("comments").where("postid",isEqualTo:
snapshot.data.docs[index].id).get().toString().length}')
}发布于 2021-04-28 20:13:55
所以我知道这个问题的解决方案,所以我发布了上面问题的例子
StreamBuilder(stream:FirebaseFirestore.instance.collection("comment").where("postid",isEqualTo: snapshot.data.docs[index].id).snapshots(),
builder: (context,projsnap){
final int documents = projsnap.data.docs.length;
return Text('${documents}');
}),https://stackoverflow.com/questions/67281134
复制相似问题