StreamBuilder for firestore not displaying the data on the screen

Viewed 25

I am trying to create a chat application and I have collections of data that represent the messages, I added a streambuilder that will display the data but nothing shows up on the screen. It also doesn't return an error so I'm not sure what the problem is

StreamBuilder<QuerySnapshot>(
              stream: FirebaseFirestore.instance
                  .collection('chatRooms')
                  .doc(chatId)
                  .collection('chats')
                  .orderBy("lastMessageTime", descending: false)
                  .snapshots(),
              builder: (context, snapshot) {
                if (!snapshot.hasData) {
                  return const Center(child: CircularProgressIndicator());
                } else {
                  return ListView.builder(
                      itemCount: snapshot.data!.docs.length,
                      itemBuilder: ((context, index) {
                        DocumentSnapshot userSnaps =
                            snapshot.data!.docs[index];
                        return Center(child: Text(userSnaps["message"]));
                      }));
                }
              }),

When I click the send button, Nothing appears on the screen, Please help

0 Answers
Related