import '../../../../food_delivery_client.dart';

class WCachedNetworkImage extends StatelessWidget {
  const WCachedNetworkImage({
    super.key,
    this.borderRadius,
    required this.imageUrl,
    this.height,
    this.width,
    this.fit,
  });

  final BorderRadius? borderRadius;
  final String imageUrl;
  final double? height;
  final double? width;
  final BoxFit? fit;

  @override
  Widget build(BuildContext context) {
    return ClipRRect(
      borderRadius: borderRadius ?? AppUtils.kBorderRadius20,
      child: CachedNetworkImage(
        imageUrl: imageUrl,
        height: height ?? 155,
        width: width ?? context.w,
        fit: fit ?? BoxFit.cover,
        errorWidget: (context, url, error) =>
            const Center(child: Icon(Icons.error, color: AppColors.cRed)),
        placeholder: (context, url) => Skeletonizer(
          enabled: true,
          child: Container(
            height: height ?? 150,
            width: width ?? context.w,
            color: AppColors.cE6E6E6,
          ),
        ),
      ),
    );
  }
}
