Reputation: 12602
I am working with ImageCarousel library. I have image URLs in a list that I am getting from my server and now I want to show these images in an ImageCarousel. I've tried many methods but I am unable to pass the whole list. I am stuck with this piece of code, please help me.
Here is my code:
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,
),
Upvotes: 0
Views: 203
Reputation: 6033
You can just pass the networkImages
List to the ImageCarousel
. Something like this:
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,
),
Upvotes: 1