Baseflow / Baseflow/flutter_cached_network_image

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

Open
#352 1 comment 8 reactions 0 assignees View on GitHub
type: enhancement
Dominant language
Dart
Stars
2.6k
Forks
731
Avg merge
3d 9h
Merged PRs (30d)
1

Description

## 🚀 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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in CachedNetworkImageState.didUpdateWidget and trace how imageUrl changes reset the stream and image holders. Review BaseCacheManager.removeFile for the existing cache-removal behavior, then determine how a per-widget force-reload condition should trigger a fresh download when the URL is unchanged. Done means users can force a reload for changed image content on iOS and Android.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
mobile-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.