Home > Net >  Ask how to use the extended_image package in flutter
Ask how to use the extended_image package in flutter

Time:02-04

everyone here. I have a question about the extended_image package.

Extended_image was installed for cache. I found that the default value for cache is true. If I use ExtendedImage.network, does it automatically cache?

And is there a way to use the cache image or to confirm that the cache image is used?

Please give us a lot of guidance.

  1. How to cache network image when using extended_image package

  2. How to use cache image

  3. How to check that the current load image is a cache image

CodePudding user response:

Yes, by default, the ExtendedImage widget caches network images. You can use the cache property to enable or disable caching for a specific image.

If the cache is set to true, the image will be cached. To confirm that a cached image is being used, you can check the value of the observer.networkState property, which returns one of the following values:

  1. NetworkImageLoadState.none
  2. NetworkImageLoadState.loading
  3. NetworkImageLoadState.completed
  4. NetworkImageLoadState.failed

If the state is NetworkImageLoadState.completed, it means the image is loaded from the cache.

CodePudding user response:

By default ExtendedImage.network automatically stores loaded images to cache using the image URL as the key, you can set the cache parameter to false if you want to disable this behavior.

Also if you want to set your own cache key, you can use the cacheKey property.

  • Related