feat: Implement image cache eviction for S3 images and enhance image loading error handling.

This commit is contained in:
pradeepkumar
2026-03-14 15:26:08 +05:30
parent ad94db5620
commit 7b9c19ec67
4 changed files with 53 additions and 35 deletions

View File

@@ -60,13 +60,17 @@ class _S3ImageState extends State<S3Image> {
return;
}
final url = await ImageUrlResolver.instance.resolve(widget.imageUrl);
if (mounted) {
setState(() {
_resolvedUrl = url;
_loading = false;
_failed = url == null;
});
try {
final url = await ImageUrlResolver.instance.resolve(widget.imageUrl);
if (mounted) {
setState(() {
_resolvedUrl = url;
_loading = false;
_failed = url == null;
});
}
} catch (_) {
if (mounted) setState(() { _loading = false; _failed = true; });
}
}
@@ -102,12 +106,13 @@ class _S3ImageState extends State<S3Image> {
return CachedNetworkImage(
imageUrl: _resolvedUrl!,
cacheKey: widget.imageUrl,
width: widget.width,
height: widget.height,
fit: widget.fit,
alignment: widget.alignment,
placeholder: (ctx, _) => _buildPlaceholder(ctx),
errorWidget: (ctx, _, __) => _buildError(ctx),
errorWidget: (ctx, _, _) => _buildError(ctx),
);
}
}