Jaime
Jaime

Reputation: 894

Flutter carousel pro image cache How to

I'm able to load images into Carousel (carousel_pro) using NetworkImage, but using AdvancedNetworkImage throws the error: type 'Image' is not a subtype of type 'ImageProvider'

{
          return Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              AspectRatio(
                aspectRatio: 0.9,
                child: Carousel(
                  images: snapshot["images"].map((url){
                    return Image(
                      image: AdvancedNetworkImage(url, useDiskCache: true));
                  }).toList(),
                  dotSize: 4.0,
                  dotSpacing: 15.0,
                  dotBgColor: Colors.transparent,
                  dotColor: Colors.red,
                  autoplay: false,
                ),
              ),
            ],
          );
        }

Could any please enlighten me how to solve this, I mean caching the images that load in the Carousel?

Upvotes: 0

Views: 2709

Answers (1)

Jaime
Jaime

Reputation: 894

Ok, solved it by changing return Image(image: AdvancedNetworkImage(url, useDiskCache: true)); to return CachedNetworkImage(url);

Upvotes: 1

Related Questions