widgetChatBuildListMessage static method

Widget widgetChatBuildListMessage(
  1. dynamic groupChatId,
  2. dynamic listMessage,
  3. dynamic currentUserId,
  4. dynamic peerAvatar,
  5. dynamic listScrollController,
  6. dynamic stCollection,
)

Implementation

static Widget widgetChatBuildListMessage(groupChatId, listMessage,
    currentUserId, peerAvatar, listScrollController, var stCollection) {
  Stream<QuerySnapshot> _streamChatData;
  _streamChatData =
      ChatDBFireStore().streamChatDataList(stCollection, groupChatId);

  return Flexible(
    child: groupChatId == ''
        ? Center(
            child: CircularProgressIndicator(
                valueColor: AlwaysStoppedAnimation<Color>(themeColor)))
        : StreamBuilder<QuerySnapshot>(
            stream: _streamChatData,
            builder: (context, snapshot) {
              if (!snapshot.hasData) {
                return Center(
                    child: CircularProgressIndicator(
                        valueColor:
                            AlwaysStoppedAnimation<Color>(themeColor)));
              } else {
                listMessage = snapshot.data!.docs;
                return ListView.builder(
                  padding: EdgeInsets.all(10.0),
                  itemBuilder: (context, index) =>
                      ChatWidget.widgetChatBuildItem(
                          context,
                          listMessage,
                          currentUserId,
                          index,
                          snapshot.data!.docs[index],
                          peerAvatar),
                  itemCount: snapshot.data!.docs.length,
                  reverse: true,
                  controller: listScrollController,
                );
              }
            },
          ),
  );
}