cachedImageForItem function

Widget cachedImageForItem(
  1. String url, {
  2. double? height,
  3. double? width,
  4. BoxFit? boxFit,
})

Returns a network image widget with custom caching support. Features:

  • Uses CachedNetworkImage to 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),
  );
}