From 83a63d7e30f954c60e01093058e40bbfd0bec1a9 Mon Sep 17 00:00:00 2001 From: Rene Floor Date: Sun, 31 Dec 2023 13:22:22 +0100 Subject: [PATCH] Remove duplicate error reporting --- cached_network_image/CHANGELOG.md | 3 +++ cached_network_image/example/lib/main.dart | 9 +++++++++ .../lib/src/image_provider/_image_loader.dart | 7 ------- .../image_provider/cached_network_image_provider.dart | 2 -- cached_network_image/pubspec.yaml | 6 +++--- cached_network_image_platform_interface/CHANGELOG.md | 3 +++ .../lib/cached_network_image_platform_interface.dart | 2 -- cached_network_image_platform_interface/pubspec.yaml | 2 +- .../cached_network_image_platform_interface_test.dart | 1 - cached_network_image_web/CHANGELOG.md | 3 +++ .../lib/cached_network_image_web.dart | 10 +--------- cached_network_image_web/pubspec.yaml | 4 ++-- .../test/cached_network_image_web_test.dart | 1 - 13 files changed, 25 insertions(+), 28 deletions(-) diff --git a/cached_network_image/CHANGELOG.md b/cached_network_image/CHANGELOG.md index 648c0a85..0d72184f 100644 --- a/cached_network_image/CHANGELOG.md +++ b/cached_network_image/CHANGELOG.md @@ -1,3 +1,6 @@ +## [3.3.1] - 2023-12-31 +* Adding an errorListener prevents automatic reporting to global error handler. + ## [3.3.0] - 2023-09-25 * Add error to ErrorListener * Update to Dart 3 diff --git a/cached_network_image/example/lib/main.dart b/cached_network_image/example/lib/main.dart index 9384941b..c639cc66 100644 --- a/cached_network_image/example/lib/main.dart +++ b/cached_network_image/example/lib/main.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:baseflow_plugin_template/baseflow_plugin_template.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; @@ -106,6 +108,13 @@ class BasicContent extends StatelessWidget { placeholder: (context, url) => const CircularProgressIndicator(), errorWidget: (context, url, error) => const Icon(Icons.error), + errorListener: (e) { + if (e is SocketException) { + print('Error with ${e.address} and message ${e.message}'); + } else { + print('Image Exception is: ${e.runtimeType}'); + } + }, ), ), _sizedContainer( diff --git a/cached_network_image/lib/src/image_provider/_image_loader.dart b/cached_network_image/lib/src/image_provider/_image_loader.dart index 808d6b80..9addf9fc 100644 --- a/cached_network_image/lib/src/image_provider/_image_loader.dart +++ b/cached_network_image/lib/src/image_provider/_image_loader.dart @@ -23,7 +23,6 @@ class ImageLoader implements platform.ImageLoader { int? maxHeight, int? maxWidth, Map? headers, - VoidCallback? errorListener, ImageRenderMethodForWeb imageRenderMethodForWeb, VoidCallback evictImage, ) { @@ -39,7 +38,6 @@ class ImageLoader implements platform.ImageLoader { maxHeight, maxWidth, headers, - (_) => errorListener?.call(), imageRenderMethodForWeb, evictImage, ); @@ -55,7 +53,6 @@ class ImageLoader implements platform.ImageLoader { int? maxHeight, int? maxWidth, Map? headers, - ErrorListener? errorListener, ImageRenderMethodForWeb imageRenderMethodForWeb, VoidCallback evictImage, ) { @@ -71,7 +68,6 @@ class ImageLoader implements platform.ImageLoader { maxHeight, maxWidth, headers, - errorListener, imageRenderMethodForWeb, evictImage, ); @@ -86,7 +82,6 @@ class ImageLoader implements platform.ImageLoader { int? maxHeight, int? maxWidth, Map? headers, - ErrorListener? errorListener, ImageRenderMethodForWeb imageRenderMethodForWeb, VoidCallback evictImage, ) async* { @@ -137,8 +132,6 @@ class ImageLoader implements platform.ImageLoader { scheduleMicrotask(() { evictImage(); }); - - errorListener?.call(e); rethrow; } finally { await chunkEvents.close(); diff --git a/cached_network_image/lib/src/image_provider/cached_network_image_provider.dart b/cached_network_image/lib/src/image_provider/cached_network_image_provider.dart index bc594abd..d853c535 100644 --- a/cached_network_image/lib/src/image_provider/cached_network_image_provider.dart +++ b/cached_network_image/lib/src/image_provider/cached_network_image_provider.dart @@ -117,7 +117,6 @@ class CachedNetworkImageProvider maxHeight, maxWidth, headers, - () => errorListener, imageRenderMethodForWeb, () => PaintingBinding.instance.imageCache.evict(key), ); @@ -171,7 +170,6 @@ class CachedNetworkImageProvider maxHeight, maxWidth, headers, - errorListener, imageRenderMethodForWeb, () => PaintingBinding.instance.imageCache.evict(key), ); diff --git a/cached_network_image/pubspec.yaml b/cached_network_image/pubspec.yaml index a67f60f4..d00f051f 100644 --- a/cached_network_image/pubspec.yaml +++ b/cached_network_image/pubspec.yaml @@ -6,14 +6,14 @@ topics: - cache - image - network-image -version: 3.3.0 +version: 3.3.1 environment: sdk: ^3.0.0 flutter: '>=3.10.0' dependencies: - cached_network_image_platform_interface: ^3.0.0 - cached_network_image_web: ^1.1.0 + cached_network_image_platform_interface: ^4.0.0 + cached_network_image_web: ^1.1.1 flutter: sdk: flutter flutter_cache_manager: ^3.3.1 diff --git a/cached_network_image_platform_interface/CHANGELOG.md b/cached_network_image_platform_interface/CHANGELOG.md index 1cc42e2e..3b5acf52 100644 --- a/cached_network_image_platform_interface/CHANGELOG.md +++ b/cached_network_image_platform_interface/CHANGELOG.md @@ -1,3 +1,6 @@ +## [4.0.0] - 2023-12-31 +* Removed errorListener from ImageLoader interface + ## [3.0.0] - 2023-09-25 * Add error to ErrorListener * Specify types diff --git a/cached_network_image_platform_interface/lib/cached_network_image_platform_interface.dart b/cached_network_image_platform_interface/lib/cached_network_image_platform_interface.dart index 6b5320a5..6f85606c 100644 --- a/cached_network_image_platform_interface/lib/cached_network_image_platform_interface.dart +++ b/cached_network_image_platform_interface/lib/cached_network_image_platform_interface.dart @@ -35,7 +35,6 @@ class ImageLoader { int? maxHeight, int? maxWidth, Map? headers, - VoidCallback? errorListener, ImageRenderMethodForWeb imageRenderMethodForWeb, VoidCallback evictImage, ) { @@ -53,7 +52,6 @@ class ImageLoader { int? maxHeight, int? maxWidth, Map? headers, - ErrorListener? errorListener, ImageRenderMethodForWeb imageRenderMethodForWeb, VoidCallback evictImage, ) { diff --git a/cached_network_image_platform_interface/pubspec.yaml b/cached_network_image_platform_interface/pubspec.yaml index b8788368..34bdcd42 100644 --- a/cached_network_image_platform_interface/pubspec.yaml +++ b/cached_network_image_platform_interface/pubspec.yaml @@ -1,6 +1,6 @@ name: cached_network_image_platform_interface description: Platform interface for CachedNetworkImage -version: 3.0.0 +version: 4.0.0 homepage: https://github.com/Baseflow/flutter_cached_network_image environment: diff --git a/cached_network_image_platform_interface/test/cached_network_image_platform_interface_test.dart b/cached_network_image_platform_interface/test/cached_network_image_platform_interface_test.dart index 3fa33952..6d0afdff 100644 --- a/cached_network_image_platform_interface/test/cached_network_image_platform_interface_test.dart +++ b/cached_network_image_platform_interface/test/cached_network_image_platform_interface_test.dart @@ -25,7 +25,6 @@ void main() { null, null, null, - null, ImageRenderMethodForWeb.HttpGet, () => {}, ), diff --git a/cached_network_image_web/CHANGELOG.md b/cached_network_image_web/CHANGELOG.md index 0bc8e714..c1a24303 100644 --- a/cached_network_image_web/CHANGELOG.md +++ b/cached_network_image_web/CHANGELOG.md @@ -1,3 +1,6 @@ +## [1.1.1] - 2023-12-31 +* Removed errorListener from ImageLoader interface + ## [1.1.0] - 2023-09-25 * Add error to ErrorListener * Specify types diff --git a/cached_network_image_web/lib/cached_network_image_web.dart b/cached_network_image_web/lib/cached_network_image_web.dart index dfdd7708..4e9655ce 100644 --- a/cached_network_image_web/lib/cached_network_image_web.dart +++ b/cached_network_image_web/lib/cached_network_image_web.dart @@ -7,7 +7,7 @@ import 'dart:ui' as ui; import 'package:cached_network_image_platform_interface' '/cached_network_image_platform_interface.dart' as platform - show ImageLoader, ErrorListener, ImageRenderMethodForWeb; + show ImageLoader, ImageRenderMethodForWeb; import 'package:flutter/material.dart'; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; @@ -24,7 +24,6 @@ class ImageLoader implements platform.ImageLoader { int? maxHeight, int? maxWidth, Map? headers, - VoidCallback? errorListener, platform.ImageRenderMethodForWeb imageRenderMethodForWeb, VoidCallback evictImage, ) { @@ -40,7 +39,6 @@ class ImageLoader implements platform.ImageLoader { maxHeight, maxWidth, headers, - (_) {}, imageRenderMethodForWeb, evictImage, ); @@ -56,7 +54,6 @@ class ImageLoader implements platform.ImageLoader { int? maxHeight, int? maxWidth, Map? headers, - ValueChanged? errorListener, platform.ImageRenderMethodForWeb imageRenderMethodForWeb, VoidCallback evictImage, ) { @@ -72,7 +69,6 @@ class ImageLoader implements platform.ImageLoader { maxHeight, maxWidth, headers, - errorListener, imageRenderMethodForWeb, evictImage, ); @@ -87,7 +83,6 @@ class ImageLoader implements platform.ImageLoader { int? maxHeight, int? maxWidth, Map? headers, - platform.ErrorListener? errorListener, platform.ImageRenderMethodForWeb imageRenderMethodForWeb, VoidCallback evictImage, ) { @@ -102,7 +97,6 @@ class ImageLoader implements platform.ImageLoader { maxHeight, maxWidth, headers, - errorListener, evictImage, ); case platform.ImageRenderMethodForWeb.HtmlImage: @@ -119,7 +113,6 @@ class ImageLoader implements platform.ImageLoader { int? maxHeight, int? maxWidth, Map? headers, - platform.ErrorListener? errorListener, VoidCallback evictImage, ) async* { try { @@ -151,7 +144,6 @@ class ImageLoader implements platform.ImageLoader { scheduleMicrotask(() { evictImage(); }); - errorListener?.call(e); rethrow; } await chunkEvents.close(); diff --git a/cached_network_image_web/pubspec.yaml b/cached_network_image_web/pubspec.yaml index 559457ab..23a2969f 100644 --- a/cached_network_image_web/pubspec.yaml +++ b/cached_network_image_web/pubspec.yaml @@ -1,6 +1,6 @@ name: cached_network_image_web description: Web implementation of CachedNetworkImage -version: 1.1.0 +version: 1.1.1 homepage: https://github.com/Baseflow/flutter_cached_network_image environment: @@ -8,7 +8,7 @@ environment: flutter: '>=3.10.0' dependencies: - cached_network_image_platform_interface: ^3.0.0 + cached_network_image_platform_interface: ^4.0.0 flutter: sdk: flutter flutter_cache_manager: ^3.3.1 diff --git a/cached_network_image_web/test/cached_network_image_web_test.dart b/cached_network_image_web/test/cached_network_image_web_test.dart index 649f712f..382c9c90 100644 --- a/cached_network_image_web/test/cached_network_image_web_test.dart +++ b/cached_network_image_web/test/cached_network_image_web_test.dart @@ -24,7 +24,6 @@ void main() { null, null, null, - null, ImageRenderMethodForWeb.HttpGet, () => {}, );