添加文档事件中的Firebase文档流?

时间:2018-09-17 10:32:07

标签: firebase stream dart flutter google-cloud-firestore

我有一个Stream获取Firebase集合的最新快照,我需要附加一个事件来向下滚动以显示该文档集合的列表视图

 StreamBuilder<QuerySnapshot>(
                  stream: model.getConversation(widget.channelId),
                  builder: (BuildContext context,
                      AsyncSnapshot<QuerySnapshot> snapShot) {
                    if (snapShot.hasError) {
                      return Center(
                        child:
                            Text('Please check your Internet Connection'),
                      );
                    } else if (snapShot.data.documents.length == 0) {
                      return Center(
                        child: Text('no Messages yet'),
                      );
                    } else {
                      return ListView(
                        shrinkWrap: true,
                        addAutomaticKeepAlives: true,
                        controller: _scrollCont,
                        children: snapShot.data.documents
                            .map((DocumentSnapshot document) {
                          return Msg(
                            text: document.data['message'].toString(),
                            msgTime: document.data['creation_time'],
                            isMe: document.data['sender_id'] ==
                                model.user.userProfile.id,
                          );
                        }).toList(),
                      );
                    }
                  })

我需要做的就是在任何新消息到达消息集合时将视图滚动到最后一个元素,

0 个答案:

没有答案