how to handle 404 exception with CachedNetworkImage in flutter how to handle 404 exception with CachedNetworkImage in flutter dart dart

how to handle 404 exception with CachedNetworkImage in flutter


The IDE is telling you that there is an exception, but actually it's ok. The reason is apparently because the Dart VM doesn't recognize it as a caught exception even though it is. Just press the continue button or uncheck the breakpoint for uncaught exceptions. You'll see that your errorWidget will show up.

enter image description here

The author of the plugin actually added a FAQ about this issue.


You could use the Transparent image plugin for this.Link to the Transparent image pub page

Example code: (Taken from the Transparent image page)

    FadeInImage.memoryNetwork(    placeholder: kTransparentImage,    image: 'https://picsum.photos/250?image=9',  ),);

Hope this is what you needed.