From 68e814064a229ffcf31057ee98fb7c634f90f4b6 Mon Sep 17 00:00:00 2001 From: Edouard Marquez Date: Fri, 5 Jul 2024 08:37:24 +0200 Subject: [PATCH] fix: Raster cache should support `ErrorBuilder` (#5475) * Raster cache should support `ErrorBuilder` * Prevent duplicated code --- .../cards/category_cards/raster_cache.dart | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 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 312ca179244..dd86ec4c515 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, @@ -30,15 +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, + ) => + _localAssetWidget(fullFilenames), + ); + } + + RasterAsyncAsset _localAssetWidget(List fullFilenames) { + return RasterAsyncAsset( + AssetCacheHelper( + fullFilenames, + iconUrl!, + width: width, + height: height, + ), ); } }