flutter_cached_network_image icon indicating copy to clipboard operation
flutter_cached_network_image copied to clipboard

Add condition to check for new image instead of comparing by imageUrl

Open trietbui85 opened this issue 5 years ago • 1 comments

🚀 Feature Requests

I notice in CachedNetworkImageState, you're using the imageUrl for checking if image has been changed

  void didUpdateWidget(CachedNetworkImage oldWidget) {
    if (oldWidget.imageUrl != widget.imageUrl) {
      _streamBuilderKey = UniqueKey();
      if (!widget.useOldImageOnUrlChange) {
        _disposeImageHolders();
        _imageHolders.clear();
      }
    }
    super.didUpdateWidget(oldWidget);
  }

While it would work in most case, but in my case it doesn't work: after loading new avatar, the backend still return the same image url, but I know its content is changed.

Contextualize the feature

CachedNetworkImage should has a condition to let user force reload image. I know there is BaseCacheManager.removeFile but it's used for remove image from the cache.

Describe the feature

I think about each CachedNetworkImage will has a ForceReload object (like the CacheManager). In BLoC side, when need to force reload, we will update the ForceReload. After that, CachedNetworkImageState.didUpdateWidget and will use ForceReload, realize that it needs to force download image.

Platforms affected (mark all that apply)

  • [x] :iphone: iOS
  • [x] :robot: Android

trietbui85 avatar Mar 16 '20 09:03 trietbui85

my use-case is different, but the cause is the same line if (oldWidget.imageUrl != widget.imageUrl)

in may case I don't want the image re-downloaded when the (fullUrl) changes

and what I mean by the full url hear is that the image url from aws s3 is changed with every request for the same image example https://example.amazonaws.com/xa6poltho72ik19vywvhpvrulz5b?response-content-disposition=inline%3B%20filename%3D%2269C95E17-0545-4753-BF76-3F292B2D11C6-1719844237365.jpeg%22%3B%20filename%2A%3DUTF-8%27%2769C95E17-0545-4753-BF76-3F292B2D11C6-1719844237365.jpeg&response-content-type=image%2Fjpeg&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAVZUP6sdfd3QBDKOUVZ%2F20240709%2Fme-sfssf-1%2Fs3%2Faws4_request&X-Amz-Date=20240709T170114Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=da7ca86c19f2a29fd383aa53667c6e0e979412b7ab93e2ebe5d19d38

So it will be better if I updating (re-downloaded) depend on the image no the url or somehow can determine the pure image url.

abdullahalamodi avatar Aug 08 '24 08:08 abdullahalamodi