mchome / flutter_advanced_networkimage

flutter advanced network image provider
https://pub.dev/packages/flutter_advanced_networkimage
MIT License
285 stars 180 forks source link

Evict/Delete Memory Cache #146

Closed EricPHassey closed 4 years ago

EricPHassey commented 4 years ago

Even when I set useDiskCache to false and/or evict the cache, the same "cached" image appears from the same url even when I change the image on this url.

It appears the memory cache is storing this image. When I set 'disableMemoryCache' to false, this works correctly, however as mentioned, it creates other production issues.

Anyway to remove/revoke the memory cache on a case by case example (instead of disabling it for all images?) Would certainly solve my problem.

mchome commented 4 years ago

ImageProvider class has a method called evict.

EricPHassey commented 4 years ago

Thanks for the response @mchome As always I appreciate your promptness.

I've tried doing the following to no such luck:

      await AdvancedNetworkImage(cameraImages[i].url).evict();
      await AdvancedNetworkImage(cameraImages[i].url.hashCode.toString()).evict();

      await DiskCache().evict(cameraImages[i].url);
      await DiskCache().evict(cameraImages[i].url.hashCode.toString());

It still loads the wrong image even after I do those. Any chance I'm using it wrong?

EricPHassey commented 4 years ago

@mchome Not sure if there's a better solution, but this appeared to have solved the problem for me. Makes your package super powerful now.

PaintingBinding.instance.imageCache.clear(); DiskCache().evict(cameraImages[i].url.hashCode.toString());

As the above code has resolved my problems, I'm going to close this.