cachedImageForItem function
Returns a network image widget with custom caching support. Features:
- Uses
CachedNetworkImageto cache images locally. - Uses a custom cache manager for better cache control.
- Displays a loading indicator while the image is downloading.
- Shows an error icon if the image fails to load.
Parameters:
url: Image URL to load.height: Optional image height.width: Optional image width.boxFit: Optional fit behavior for the image.
Implementation
Widget cachedImageForItem(
String url, {
double? height,
double? width,
BoxFit? boxFit,
}) {
// print("mobile side ");
return CachedNetworkImage(
imageUrl: url,
height: height,
width: width,
fit: boxFit,
cacheManager: CustomCacheManager(),
placeholder: (_, __) => const Center(
child: CircularProgressIndicator(
color: AppColors.blueColor,
strokeWidth: 3,
)),
errorWidget: (_, __, ___) => const Icon(Icons.error),
);
}