flutter_cached_network_image icon indicating copy to clipboard operation
flutter_cached_network_image copied to clipboard

ErrorWidget only working once

Open peacemaker123456 opened this issue 3 years ago • 5 comments

Thanks for the great package first of all.

When starting the app and coming across a broken url, the errorWidget is shown after a short loading phase (during which the placeholder is shown). That's working as expected. But once I encounter an image with the same url (e.g. pushing a detail page), the placeholder is shown forever, instead of switching to the errorWidget. No matter whether state is disposed, the errorWidget will never be shown again until a Hot Restart is being performed.

Since my placeholder widget (a shimmer loading animation), differs from the errorWidget, this creates the impression of a broken connection, which might confuse some users.

It think it's quite a big issue (at least for me), so I would appreciate any solution proposals.

peacemaker123456 avatar Nov 18 '22 19:11 peacemaker123456

I am experiencing the exact same bug. The errorWidget seems to work on first load, but if you scroll down and back up, it no longer displays and will only displace the placeholder. I do not remember this being an issue in the past.

DennisAshford avatar Dec 07 '22 18:12 DennisAshford

Were you able to figure this out? The error widget still seems to not be working properly.

DennisAshford avatar Mar 14 '23 20:03 DennisAshford

@renefloor could you please have a look at this issue? Or maybe provide some insight where one would have to adapt the code?

peacemaker123456 avatar Mar 14 '23 23:03 peacemaker123456

I played around with this and it looks like this only happens when maxWidthDiskCache and/or maxHeightDiskCache is set. Without these properties the errorWidget gets called every time as expected.

I tried to debug this a little bit and it seems like it has something to do with flutters internal Image Cache: Even though flutter_cached_network_image calls PaintingBinding.instance.imageCache.evict(key) when something goes wrong, which in turn removes the pending image from the internal _pendingImages` HashMap from flutters image cache, the next time the erroneous image gets loaded the ImageCache still seems to have the image cached somehow?

hffmnn avatar Aug 01 '23 13:08 hffmnn