![](/img/trans.png)
[英]type 'List<Map<String, dynamic>>' is not a subtype of type 'Map<dynamic, dynamic>'
[英]type 'List<dynamic>' is not a subtype of type 'String'
return ListTile(
shape: RoundedRectangleBorder(
side: BorderSide(width: 3.0, color: Colors.grey.shade300)),
title: Text(documentSnapshot['name']),
subtitle: Text(documentSnapshot['price']),
leading: Container(
height: 80,
width: 80,
child: Image.network(documentSnapshot['image']), //i got error here to display the product in my shopping cart because i display multiple images
),
您可以使用以下代码
ListView.builder(
itemCount : documentSnapshot.length,
itemBuilder:(context, index) {
return ListTile(
shape: RoundedRectangleBorder(
side: BorderSide(width: 3.0, color: Colors.grey.shade300)),
title: Text(documentSnapshot[index]['name']),
subtitle: Text(documentSnapshot[index]['price']),
leading: Container(
height: 80,
width: 80,
child: Image.network(documentSnapshot[index]['image']),
);
}
);
你得到的错误基本上是因为你从你的数据库接收数据列表并且你试图将它们分配为单个数据。 这是不可能的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.