Baseflow / Baseflow/flutter_cached_network_image
CacheNetworkImageProvider hangs/does not proceed when maxWidth/maxHeight are set and the image is not available
- Dominant language
- Dart
- Stars
- 2.6k
- Forks
- 731
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 1
Description
## 🐛 Bug Report
This is cross posted from cache_manager since im not sure if the actual problem is here or there. https://github.com/Baseflow/flutter_cache_manager/issues/439
In summary, if an image attempt is made using `CachedNetworkImageProvider` `.resolve`, but its not present (a standard 404 webpage is presented instead of an image) then an image error/exception occurs and can be handled. In my case, Im using a `FutureBuilder` and when this happens I return a status code and the FutureBuilder can present my own error widget. This will happen every time the same image request is made (say if a widget with the missing image is reopened).
HOWEVER,
If the same `CachedNetworkImageProvider` is now supplied with `maxWidth` (or `maxHeight`), then only the first time the image request is made using `CachedNetworkImageProvider` `.resolve` then do we get the catchable exception.
If now the widget is closed and re-opened to make the same exact `CachedNetworkImageProvider` `.resolve` on the same image, then nothing happens. No errors, nothing. This leaves the `FutureBuilder` in a forever state of `ConnectionStatus.waiting`.
I *THINK* the problem is that the image stream never closes when the exception happens, which leads to a potential memory leak as well as not allowing us to get a new stream? Im not sure if that makes total sense, but I can't understand this otherwise.
Ive tracked the problem to around here, at least in regards to where the exception is thrown https://github.com/Baseflow/flutter_cached_network_image/blob/develop/cached_network_image/lib/src/image_provider/_image_loader.dart#L129C12-L129C47
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.