Flatter firebase获取所有文档';数组类型字段

Flatter firebase获取所有文档';数组类型字段,firebase,flutter,google-cloud-firestore,Firebase,Flutter,Google Cloud Firestore,我有一个flatter项目,我在其中显示产品及其信息,但在firebase中,我将图像类型从字符串转换为数组,并且由于类型更改而面临问题。在另一个类中,我有相同的示例,但仅限于一个文档,这不适用于我的案例 void getImage() async { await FirebaseFirestore.instance .collection('Product') .doc(docID) .get() .then((docum

我有一个flatter项目,我在其中显示产品及其信息,但在firebase中,我将图像类型从字符串转换为数组,并且由于类型更改而面临问题。在另一个类中,我有相同的示例,但仅限于一个文档,这不适用于我的案例

void getImage() async {
    await FirebaseFirestore.instance
        .collection('Product')
        .doc(docID)
        .get()
        .then((document) {
      imageLists = document.data()['image'];
    });
  }
是否仍有方法使此代码接受数组类型

StreamBuilder<QuerySnapshot>(
              stream: product.snapshots(),
              builder: (context, snapshot) {
                if (snapshot.hasData) {
                  return Flexible(
                    child: GridView.builder(
                        itemCount: snapshot.data.docs.length,
                        gridDelegate:
                            SliverGridDelegateWithFixedCrossAxisCount(
                          crossAxisCount: 2,
                        ),
                        itemBuilder: (context, index) {
                          return Padding(
                            padding: const EdgeInsets.fromLTRB(8, 16, 8, 0),
                            child: Image.network(
                              // here
                              snapshot.data.docs[index].get('image'),
                              width: 150,
                              height: 120,
                            ),
                          );                             
                        }),
                  );
                }
              }),
        
StreamBuilder(
流:product.snapshots(),
生成器:(上下文,快照){
if(snapshot.hasData){
回程灵活(
子项:GridView.builder(
itemCount:snapshot.data.docs.length,
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
交叉轴计数:2,
),
itemBuilder:(上下文,索引){
返回填充(
padding:const EdgeInsets.fromLTRB(8,16,8,0),
孩子:Image.network(
//这里
snapshot.data.docs[index].get('image'),
宽度:150,
身高:120,
),
);                             
}),
);
}
}),

好吧,我刚刚找到了一个解决方案来取代这个代码:

snapshot.data.docs[index].get('image'),
用这个

snapshot.data.docs[index]['image'][0],
问题是第一个代码只接受字符串类型,通过在数组括号中添加字段,它知道该类型是数组,并为数组索引添加额外的括号