title: How to access data from firestore using streambuilder flutter
body: <p>I want to access data from firestore but there are errors, how can i do that?
  I cant use .docs in snapshot.</p>
  <pre><code>StreamBuilder(
                  stream: messageStream,
                  builder: (context, snapshot) {
                    return snapshot.hasData
                        ? ListView.builder(
                            padding: EdgeInsets.only(bottom: 70, top: 16),
                            reverse: true,
                            itemCount: snapshot.data.docs.length, // error
                            itemBuilder: (BuildContext context, int index) {
                              DocumentSnapshot ds =
                                  snapshot.data!.docs[index]; // error
                              return _buildMessage(
                                  ds[&quot;message&quot;], myUserName == ds[&quot;sendBy&quot;]);
                            },
                          )
                        : Center(
                            child: CircularProgressIndicator(),
                          );
                  },
                ),
  </code></pre>
  <p>Stream:</p>
  <pre><code>getChatRoomMessages(chatRoomId) async {
  return FirebaseFirestore.instance.collection(&quot;chatRooms&quot;).doc(chatRoomId).collection(&quot;chats&quot;).orderBy(&quot;ts&quot;, descending: true).snapshots();}
  </code></pre>