flutter_cached_network_image icon indicating copy to clipboard operation
flutter_cached_network_image copied to clipboard

Check image load status

Open sidrao2006 opened this issue 4 years ago • 8 comments

💬 Questions and Help

Is there an existing field or notifier (imageLoaded) or any other way to know without using the imageBuilder as it requires a lot of unused code.

If this method does not exist, then I would like to propose the creation of imageLoaded field or a imageLoadNotifier which is a ValueNotifier.

sidrao2006 avatar Aug 26 '20 17:08 sidrao2006

Hi @sidrao2006 ,

I'm not quite sure what you would like to see. What exactly should be returned by the onImageLoad() callback.

To see is an image has already been cached you could try DefaultCacheManager().getFileFromMemory(url); this method returns a null if the file does not exist. I assume this is what you'd expect from the imageLoaded boolean?

danielroek avatar Aug 31 '20 08:08 danielroek

@danielroek thanks for replying Yes, imageLoaded will be useful. Please ignore tye request for a callback

sidrao2006 avatar Aug 31 '20 09:08 sidrao2006

@sidrao2006 I added the enhancement label to this issue, for now you could use imageLoaded = DefaultCacheManager().getFileFromMemory(url) != null; in your code.

danielroek avatar Sep 01 '20 09:09 danielroek

Thanks a lot

sidrao2006 avatar Sep 01 '20 09:09 sidrao2006

@danielroek , can you please implement this feature soon, as DefaultCacheManager is not exposed by this package. So I will have to depend on it directly. This can cause other issues related to dependency version constraints

sidrao2006 avatar Sep 13 '20 05:09 sidrao2006

DefaultCacheManager().getFileFromMemory(url); is not really helpful because its not a callback. It doesnt tell me when the image is loaded, only if.

I tried to hack around with this, and I got this to work:

CachedNetworkImage(
  imageBuilder: (context, provider) {
    // execute your onLoad code here
    return Image(
      image: provider,
    );
  },
)

though this is basically side effects in build, which is really ugly.

clragon avatar Oct 04 '20 11:10 clragon

Any updates on this issue ? The way of using imageBuilder is not a proper solution because it can be called many times.

WatchDogsDev avatar Nov 13 '22 07:11 WatchDogsDev

I would be interested in such feature as well.

raphasauer avatar Sep 11 '23 17:09 raphasauer