Baseflow / Baseflow/flutter_cached_network_image

Need A Way To Throw Network Error

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

Description

## 🏗 Enhancement Proposal

### Pitch

In fact, we always need a way to throw out our errors when our image requests fail, but we're difficult to do this now. What we can do is just throw an error like this, but this is certainly not what we want.

```dart
CachedNetworkImage(
imageUrl: 'https://xxx.com',
errorWidget: (context, url, error) {
throw error;
},
),
```

This is a bad implementation, and it may cause our errorWidget to display an exception. I think that network errors should be thrown from inside the component and caught by A at the business level. This will help us in error handling and error collection. The outer api should look like the following.

```dart
try {
CachedNetworkImage(
imageUrl: 'https://xxx.com',
errorWidget: Icon(Icons.error),
),
} catch(e) {
// something to do in error
throw e;
}
```

Thanks.

### Platforms affected (mark all that apply)
- [x] :iphone: iOS
- [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.