Baseflow / Baseflow/flutter_cache_manager

url 404 and retry always 404

Open
#473 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
809
Forks
510
Avg merge
6m
Merged PRs (30d)
1

Description

## 💬 Questions and Help

Here I'm using cached_network_image to loading network image. It may not exists with the giving image url, when I get 404 from errorListener, I async image to the url to make sure url is available. After that I refresh the CachedNetworkImage, still get error 404 from errorWidget.

```
Widget imgWidget() {
return CachedNetworkImage(
imageUrl: _imageUrl,
imageBuilder: (context, imageProvider) {
return Container(
decoration: BoxDecoration(
image: DecorationImage(
image: imageProvider,
fit: widget.fit,
),
),
);
},
placeholder: (context, url) {
return widget.placeholder;
},
errorWidget: (context, url, error) {
return widget.placeholder;
},
errorListener: (e) {
if (e is HttpException) {
logger.d('----- errorListener ${e.uri.toString()} - ${e.message}');
if (e.message.contains('404')) {
_syncImage();
}
} else {
logger.d('Image Exception is: ${e.runtimeType}');
}
},
);
}

_syncImage() async {
HttpManager().syncImageToCdnUrl(_imageUrl).then((_) {
setState(() { });
}).catchError((onError) {
logger.d(onError);
});
}

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.