颤动中列表视图构建器的快照长度[已修复]

Length of snapshot for List View builder in flutter[Fixed]

我需要在 Flutter 上实现一个 ListView,我将 snapshot.data.length 作为 itemCount

的参数传递
return ListView.builder(
itemCount: snapshot.data.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(                            
snapshot.data[index].data["Identificacao"],...

然后我得到一个错误:

I/flutter ( 4647): Class 'List<DocumentSnapshot>' has no instance getter 'length'.
I/flutter ( 4647): Receiver: Instance(length:1) of '_GrowableList'
I/flutter ( 4647): Tried calling: length

很容易解决

solved the problem by replacing StreamBuilder<Object> with StreamBuilder<QuerySnapshot>. by 
default the StreamBuilder comes in this form StreamBuilder<Object>

这里有一个例子

StreamBuilder<QuerySnapshot>(
      stream: FirebaseFirestore.instance
          .collection('chats/hgjgjgjGW/messages')
          .snapshots(),
      builder: (cnxt, snapshot) {
        if (snapshot.connectionState == ConnectionState.waiting) {
          return Center(
            child: CircularProgressIndicator(),
          );
        }
        if (snapshot.hasData) {
          return ListView.builder(
            itemCount: snapshot.data!.docs.length,
            itemBuilder: (ctx, i) => Container(
              padding: EdgeInsets.all(10),
              child: Text(snapshot.data!.docs[i]['text']),
            ),
          );
        }
        return Center(
          child: Text('error'),
        );
      }),