I deleted the old file from the cache.
DefaultCacheManager().removeFile(widget.imageUrl);
But Widget is showing the old photo when rebuilding.
When I hot restart Flutter, it shows newly photo.
My Photos is on AWS S3 like storage, for example url:
http://s3.eu-central-1.wasabisys.com/yazilimsalcozumler/e6f7c36b36a420859bab1aeb5e70866c.png?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=UIYRXBBCV7TPUE8X5R2Y%2F20201114%2Feu-central-1%2Fs3%2Faws4_request&X-Amz-Date=20201114T195716Z&X-Amz-SignedHeaders=host&X-Amz-Expires=604800&X-Amz-Signature=ad2400b883e5a711bata5702102ffb5fd15rd4fb8524130dc364ead66684c50d
Shows new uploaded photo.
Version: ^2.3.2+1
Platform:
That's right. The image is read from the storage, decoded and stored in memory in the Flutter Image cache.
You need to also remove it from that cache. There is a helper method in CachedNetworkImage that removes it both from the storage cache as from the memory cache: CachedNetworkImage.evictFromCache(url)
https://pub.dev/documentation/cached_network_image/latest/cached_network_image/CachedNetworkImage/evictFromCache.html
Hello @renefloor in theory this is nice but when you rebuild apps old urls should not be called and i'm having a weird bug where the cache manager is popping up deprecated links and causing errors. I cannot remove urls i don't know about so how can we automate this process?
@renefloor its very strage, but CachedNetworkImage.evictFromCache doesnt work for me... Only after restart app it works
@renefloor its very strage, but
CachedNetworkImage.evictFromCachedoesnt work for me... Only after restart app it works
@mrxten in the example here https://github.com/Baseflow/flutter_cached_network_image/pull/462#issue-483614269 I had to put a small delay, does that work for you? Can you try this example?
Hello @renefloor in theory this is nice but when you rebuild apps old urls should not be called and i'm having a weird bug where the cache manager is popping up deprecated links and causing errors. I cannot remove urls i don't know about so how can we automate this process?
@nicolasvahidzein I don't really understand what you mean here. If the app calls an old url that means the app is trying to show that image right? I don't know what the logic is in your app that tries to show images that aren't there anymore. If an old url is still in the cache this shouldn't give errors, because it shows it from the cache.
@renefloor yes, it seems removing photo from cache need some time, but why it works out of Future? It works a bit strange. sometimes 100 miliseconds enough to additional awaiting, sometime 1 second not...
@renefloor I found a better way for update showing image after evict. Do not use delay, but just change key from widget.
Hello @renefloor yes i couldn't explain it. I reran the app and it was fine. I'll chalk it up to a bug and let you know if it happens again.
Most helpful comment
That's right. The image is read from the storage, decoded and stored in memory in the Flutter Image cache.
You need to also remove it from that cache. There is a helper method in CachedNetworkImage that removes it both from the storage cache as from the memory cache:
CachedNetworkImage.evictFromCache(url)https://pub.dev/documentation/cached_network_image/latest/cached_network_image/CachedNetworkImage/evictFromCache.html