flutter_cached_network_image
flutter_cached_network_image copied to clipboard
Check image load status
💬 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.
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 thanks for replying Yes, imageLoaded will be useful. Please ignore tye request for a callback
@sidrao2006 I added the enhancement label to this issue, for now you could use imageLoaded = DefaultCacheManager().getFileFromMemory(url) != null;
in your code.
Thanks a lot
@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
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.
Any updates on this issue ? The way of using imageBuilder is not a proper solution because it can be called many times.
I would be interested in such feature as well.