From 63d1f3a38f0a40116a135ea22f775ae4cfdb34ee Mon Sep 17 00:00:00 2001 From: Edouard Marquez Date: Thu, 4 Jul 2024 17:53:34 +0200 Subject: [PATCH 1/2] Raster cache should support `ErrorBuilder` --- .../lib/cards/category_cards/raster_cache.dart | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/smooth_app/lib/cards/category_cards/raster_cache.dart b/packages/smooth_app/lib/cards/category_cards/raster_cache.dart index 312ca179244..55dc5f709e7 100644 --- a/packages/smooth_app/lib/cards/category_cards/raster_cache.dart +++ b/packages/smooth_app/lib/cards/category_cards/raster_cache.dart @@ -17,6 +17,7 @@ class RasterCache extends AbstractCache { if (fullFilenames.isEmpty) { return getDefaultUnknown(); } + return Image.network( iconUrl!, width: width, @@ -39,6 +40,20 @@ class RasterCache extends AbstractCache { ), ); }, + errorBuilder: ( + final BuildContext context, + final Object error, + final StackTrace? stackTrace, + ) { + return RasterAsyncAsset( + AssetCacheHelper( + fullFilenames, + iconUrl!, + width: width, + height: height, + ), + ); + }, ); } } From 2652c160a77d88c7e9483937b040be00209d1213 Mon Sep 17 00:00:00 2001 From: Edouard Marquez Date: Fri, 5 Jul 2024 08:27:21 +0200 Subject: [PATCH 2/2] Prevent duplicated code --- .../cards/category_cards/raster_cache.dart | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/packages/smooth_app/lib/cards/category_cards/raster_cache.dart b/packages/smooth_app/lib/cards/category_cards/raster_cache.dart index 55dc5f709e7..dd86ec4c515 100644 --- a/packages/smooth_app/lib/cards/category_cards/raster_cache.dart +++ b/packages/smooth_app/lib/cards/category_cards/raster_cache.dart @@ -31,29 +31,25 @@ class RasterCache extends AbstractCache { if (loadingProgress == null) { return child; } - return RasterAsyncAsset( - AssetCacheHelper( - fullFilenames, - iconUrl!, - width: width, - height: height, - ), - ); + return _localAssetWidget(fullFilenames); }, errorBuilder: ( final BuildContext context, final Object error, final StackTrace? stackTrace, - ) { - return RasterAsyncAsset( - AssetCacheHelper( - fullFilenames, - iconUrl!, - width: width, - height: height, - ), - ); - }, + ) => + _localAssetWidget(fullFilenames), + ); + } + + RasterAsyncAsset _localAssetWidget(List fullFilenames) { + return RasterAsyncAsset( + AssetCacheHelper( + fullFilenames, + iconUrl!, + width: width, + height: height, + ), ); } }