Skip to content

Commit

Permalink
Merge pull request #937 from robert-northmind/bugfix/emit_error_via_s…
Browse files Browse the repository at this point in the history
…tream_in_ImageLoader

Bugfix: Change how errors are reported by ImageLoader. Emits as stream instead of re-throwing
  • Loading branch information
martijn00 authored Jul 31, 2024
2 parents 536da01 + d4b4acb commit a05e39d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions cached_network_image/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [3.3.2] - 2024-04-10
* Change how errors are reported by ImageLoader. Emitting errors as streams instead of re-throwing.

## [3.3.1] - 2023-12-31
* Adding an errorListener prevents automatic reporting to global error handler.

Expand Down
2 changes: 1 addition & 1 deletion cached_network_image/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class BasicContent extends StatelessWidget {
aspectRatio: 1.6,
child: BlurHash(hash: 'LEHV6nWB2yk8pyo0adR*.7kCMdnj'),
),
imageUrl: 'https://blurha.sh/assets/images/img1.jpg',
imageUrl: 'https://blurha.sh/12c2aca29ea896a628be.jpg',
fit: BoxFit.cover,
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ class ImageLoader implements platform.ImageLoader {
yield decoded;
}
}
} on Object {
} on Object catch (error, stackTrace) {
// Depending on where the exception was thrown, the image cache may not
// have had a chance to track the key in the cache at all.
// Schedule a microtask to give the cache a chance to add the key.
scheduleMicrotask(() {
evictImage();
});
rethrow;
yield* Stream.error(error, stackTrace);
} finally {
await chunkEvents.close();
}
Expand Down
2 changes: 1 addition & 1 deletion cached_network_image/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ topics:
- cache
- image
- network-image
version: 3.3.1
version: 3.3.2
environment:
sdk: ^3.0.0
flutter: '>=3.10.0'
Expand Down

0 comments on commit a05e39d

Please sign in to comment.