0

在我的flutter firebase应用程序中,我有一个带有流生成器的评论部分,我想在有新值时使用动画列表视图制作动画,但我在将流作为列表处理时遇到问题,因为我无法通过索引流作为一个列表。有人可以帮我实现这个。这是我下面的代码:

                    StreamBuilder(
                      stream: blogCommentsRef
                          .doc(widget.blog.id)
                          .collection('blogComments')
                          .orderBy('timestamp', descending: true)
                          .snapshots(),
                      builder:
                          (BuildContext context, AsyncSnapshot snapshot) {
                        if (!snapshot.hasData) {
                          return Center(
                            child: CircularProgressIndicator(),
                          );
                        }
                        return _blogCommentCount == 0
                            ? Expanded(
                                child: Center(
                                  child: NoContents(
                                    icon: (MdiIcons.commentOutline),
                                    title: 'No comments on this blog yet,',
                                    subTitle:
                                        'You can be the first person to write your comment on this blog, ',
                                  ),
                                ),
                              )
                            : Expanded(
                                child: Scrollbar(
                                  child: AnimatedList(
                                    key: _key,
                                    initialItemCount:
                                        snapshot.data.docs.length,
                                    itemBuilder:
                                        (context, index, animation) {
                                        

                                      BlogComment blogComment =
                                          BlogComment.fromDoc(
                                              snapshot.data.docs[index]);


                                      return _build(
                                          blogComment, animation, index);
                                    },
                                  ),
                                ),
                              );
                      },
                    ),
4

0 回答 0