我正在使用ImageCarousel库。从服务器获取的列表中有图像URL,现在我想在ImageCarousel中显示这些图像。我尝试了许多方法,但无法通过整个列表。我被这段代码所困扰,请帮助我。
这是我的代码:
List<NetworkImage> networkimages;
for(int i=0 ; i< modelList[0].listThumbnails.length; i++ ) {
networkimages.add(new
NetworkImage(modelList[0].listThumbnails[i]));
}
new ImageCarousel(
<ImageProvider>[
new NetworkImage(CommonMethods.image_url + modelList[0].listThumbnails[0]),
new NetworkImage(CommonMethods.image_url + modelList[0].listThumbnails[1],),
],
interval: new Duration(seconds: 5),
showCloseButtonOnZoom: true,
),
答案 0 :(得分:1)
您只需将networkImages
列表传递到ImageCarousel
。像这样:
List<ImageProvider> networkimages = <ImageProvider>[];
for(int i=0 ; i< modelList[0].listThumbnails.length; i++ ) {
networkimages.add(new
NetworkImage(modelList[0].listThumbnails[i]));
}
new ImageCarousel(
networkimages,
interval: new Duration(seconds: 5),
showCloseButtonOnZoom: true,
),