Baseflow / Baseflow/flutter_cached_network_image

errorWidget seems to leak exceptions occasionally

Open
#780 8 comments 10 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
2.6k
Forks
731
Avg merge
3d 9h
Merged PRs (30d)
1

Description

## πŸ› 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 =
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("",
I/flutter (14804): scale: 1.0)
I/flutter (14804): Image key:
I/flutter (14804): CachedNetworkImageProvider("",
I/flutter (14804): scale: 1.0):
I/flutter (14804): CachedNetworkImageProvider("",
I/flutter (14804): scale: 1.0)
I/flutter (14804): ════════════════════════════════════════════════════════════════════════════════════════════════════
```

The widget is used like this:
```dart
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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.