Firebase 试图从firestore获取数据,但获取此错误

Firebase 试图从firestore获取数据,但获取此错误,firebase,flutter,dart,google-cloud-firestore,Firebase,Flutter,Dart,Google Cloud Firestore,我正在尝试从Firebase Firestore获取数据,但出现以下错误,一个月前我的另一个应用程序使用了相同的代码,如果您能提供帮助,那就太好了 类“List”没有实例获取程序“lengh”。 接收者:“\u GrowtableList”的实例(长度:2) 已尝试呼叫:lenght return Scaffold( body: StreamBuilder( stream: FirebaseFirestore.instance

我正在尝试从Firebase Firestore获取数据,但出现以下错误,一个月前我的另一个应用程序使用了相同的代码,如果您能提供帮助,那就太好了

类“List”没有实例获取程序“lengh”。 接收者:“\u GrowtableList”的实例(长度:2) 已尝试呼叫:lenght

    return Scaffold(
                body: StreamBuilder(
          stream: FirebaseFirestore.instance
              .collection('Sell')
              .orderBy('TS', descending: true)
              .snapshots(),
          builder: (context, snapshot) {
            if (snapshot.data == null)
              return Center(
                child: CircularProgressIndicator(
                  backgroundColor: Colors.red,
                  valueColor:
                      new AlwaysStoppedAnimation<Color>(Colors.cyan[400]),
                ),
              );
            return ListView.builder(
              itemCount: snapshot.data.documents.lenght,
              itemBuilder: (context, index) => SingleChildScrollView(
                child: Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: Container(
                    height: 120,
                    width: MediaQuery.of(context).size.width,
                    decoration: BoxDecoration(
                        color: Colors.white,
                        borderRadius: BorderRadius.circular(7),
                        boxShadow: [
                          BoxShadow(
                              color: Colors.grey[400],
                              spreadRadius: 2,
                              blurRadius: 3)
                        ]),
                    child: Row(
                      children: [
                        Container(
                          width: 120,
                          height: 120,
                          child:ClipRRect(
                                 child: Image.network(
                                    snapshot.data.documents[index]
                                        .get('image 1 Url'),
                                    fit: BoxFit.cover,
                                  ),
                                )),
                        SizedBox(width: 20),
                        Column(
                          children: [
                            Text(
                              snapshot.data.documents[index].get('name'),
                              style: TextStyle(
                                color: Colors.red,
                                fontSize: 20,
                                fontFamily: 'font',
                              ),
                            ),
                          ],
                        )
                      ],
                    ),
                  ),
                ),
              ),
            );
          },
        ));
  }
}

返回脚手架(
正文:StreamBuilder(
流:FirebaseFirestore.instance
.托收(‘出售’)
.orderBy('TS',降序:true)
.snapshots(),
生成器:(上下文,快照){
如果(snapshot.data==null)
返回中心(
子对象:循环压缩机指示器(
背景颜色:Colors.red,
valueColor:
新AlwaysStoppedAnimation(Colors.cyan[400]),
),
);
返回ListView.builder(
itemCount:snapshot.data.documents.Length,
itemBuilder:(上下文,索引)=>SingleChildScrollView(
孩子:填充(
填充:常数边集全部(8.0),
子:容器(
身高:120,
宽度:MediaQuery.of(context).size.width,
装饰:盒子装饰(
颜色:颜色,白色,
边界半径:边界半径。圆形(7),
boxShadow:[
箱形阴影(
颜色:颜色。灰色[400],
扩展半径:2,
(半径:3)
]),
孩子:排(
儿童:[
容器(
宽度:120,
身高:120,
孩子:ClipRRect(
孩子:Image.network(
快照.数据.文档[索引]
.get('image 1 Url'),
适合:BoxFit.cover,
),
)),
尺寸箱(宽度:20),
纵队(
儿童:[
正文(
snapshot.data.documents[index].get('name'),
样式:TextStyle(
颜色:颜色,红色,
尺寸:20,
fontFamily:'字体',
),
),
],
)
],
),
),
),
),
);
},
));
}
}

长度
更改为
长度

我想那是个打字错误。如果您想知道为什么
length
。这是因为您正试图获取snapshot.data.documents的长度,并将其初始化为
itemCount
,以允许列表循环您的项目。我希望这个解决方案对你有效