errorWidget seems to leak exceptions occasionally
🐛 Bug Report
I keep getting http exceptions in my debug console and error reporting service (Sentry), which shouldn't happen as I use the errorWidget builder.
The exceptions look like this:
I/flutter (14804): ══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
I/flutter (14804): The following HttpExceptionWithStatus was thrown resolving an image codec:
I/flutter (14804): HttpException: Invalid statusCode: 403, uri = <redacted>
I/flutter (14804):
I/flutter (14804): When the exception was thrown, this was the stack
I/flutter (14804):
I/flutter (14804): Image provider:
I/flutter (14804): CachedNetworkImageProvider("<redacted>",
I/flutter (14804): scale: 1.0)
I/flutter (14804): Image key:
I/flutter (14804): CachedNetworkImageProvider("<redacted>",
I/flutter (14804): scale: 1.0):
I/flutter (14804): CachedNetworkImageProvider("<redacted>",
I/flutter (14804): scale: 1.0)
I/flutter (14804): ════════════════════════════════════════════════════════════════════════════════════════════════════
The widget is used like this:
final uri = "https://firebasestorage.googleapis.com/v0/b/test-proj.appspot.com/o/broken.png?alt=media&token=b89f711d-c90d-46ed-84c8-123456789";
CachedNetworkImage(
imageUrl: uri,
errorWidget: (context, url, error) => const Padding(
padding: EdgeInsets.all(8.0),
child: Icon(Icons.broken_image_outlined),
),
imageBuilder: (context, imageProvider) {
return Container(
decoration: BoxDecoration(
image: DecorationImage(
image: CachedNetworkImageProvider(uri),
fit: BoxFit.cover,
),
color: Theme.of(context).cardTheme.color,
),
);
},
);
}
And it does as expected: It shows the Icons.broken_image_outlined for images that can't be loaded, like for example, the image that causes the exception above.
Expected behavior
I expect no exceptions to leak when the plugin seems to do what is expected.
Reproduction steps
Not sure, there's never any stack trace attached to the above exception, and as mentioned the actual behavior of the widget seems correct.
Configuration
Version: 3.2.1
Platform:
- [ ] :iphone: iOS (maybe)
- [x] :robot: Android
having same issue any solution
Seeing this as well for 403 errors and empty URLs. Any leads/fixes for this would be fantastic!
I also got the same issue with android using error builder but also got exception. Widget is working perfectly but exception should not thrown when we use error builder.
Also happening on iOS and for many Http error codes such as 500
Looks like #777 fixes it
Looks like #777 fixes it
That's a PR for an error listener, which is when you wish to react to errors in a non-widget kinda way. It most likely won't fix this, but probably a welcome feature none the less.