我正在尝试通过CircleAvatar显示来自数据库的图像数据,但是在此过程中出现了一些错误,我们将不胜感激任何建议,并且此错误也'不能将参数类型'Iterable'分配给该参数类型“ ImageProvider”。
leading: CircleAvatar(
backgroundColor: Colors.blueAccent,
backgroundImage: images.map((photo){
return Utility.imageFromBase64String(snapshot.data[index].profilepicture);
}),
),
答案 0 :(得分:1)
这是因为从返回数据中获得了Iterable类型,而不是ImageProvider类型。如果您的snapshot.data[index].profilepicture
是URL字符串。
您只能在下面使用代码。
CircleAvatar(
backgroundImage: NetworkImage(
snapshot.data[index].profilepicture,
),
),