-
-
Notifications
You must be signed in to change notification settings - Fork 656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
on loaded notification / callback needed #71
Comments
I added two callback, and tested in my project. Hope that helps |
Would love to see this merged! Exactly what I need, because images may not be available for a long time I want to hide the whole widget when it fails to load an image. This would make it possible. |
Now working with the builders |
How is the builders going to notify when the image is loaded. Placeholder builder called when start loading, error widget builder called when image loaded failed. |
@RyanYANG52 If you set the imageBuilder with a simple Image yourself you also get a callback on loaded. |
OK, thanks. |
@renefloor We need a tutorial or a section in the README cause i doubt most of us know how you do it ... |
Actually i figure it out. Posting code here for others. final VoidCallback onLoaded;
...
CachedNetworkImage(
imageUrl: "http://via.placeholder.com/200x150",
imageBuilder: (context, imageProvider) {
if (onLoaded != null) {
onLoaded();
}
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: imageProvider,
fit: BoxFit.cover,
colorFilter: ColorFilter.mode(Colors.red, BlendMode.colorBurn)),
),
);
},
placeholder: (context, url) => CircularProgressIndicator(),
errorWidget: (context, url, error) => Icon(Icons.error),
); |
This is way too complicated and too much unnecessary code in my opinion. Why do I have to write the complete |
@kwent What is |
still getting "CacheManager: Failed to download file from...." error message in VS code console panel. |
Kindly share your implemented solution. I am still searching the solution. Thanks. |
You can write something like this - since the imageBuilder is invoked after the image is loaded, if I understand correctly imageBuilder: (context, imageProvider) {
/// Onload code goes here
return Image(image: imageProvider);
} |
I agree. there should be fail and success methods just like in other image loading libraries like Glide. |
2024 and the solution given here is still not clear. |
I often need to know if the image is still loading or has successfully loaded yet.
Can you please add a callback or notification for the loading state.
The text was updated successfully, but these errors were encountered: