Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

url 404 and retry always 404 #473

Open
norman93sun opened this issue Oct 28, 2024 · 0 comments
Open

url 404 and retry always 404 #473

norman93sun opened this issue Oct 28, 2024 · 0 comments

Comments

@norman93sun
Copy link

norman93sun commented Oct 28, 2024

💬 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);
  });
}
  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant