fetchImage function

Widget fetchImage(
  1. String url, {
  2. double width = 48,
  3. double height = 48,
  4. Color? color,
  5. String? defaultImagePath,
})

Implementation

Widget fetchImage(String url,
    {double width = 48,
    double height = 48,
    Color? color,
    String? defaultImagePath}) {
  return CachedNetworkImage(
    height: height,
    width: width,
    imageUrl: url,
    color: color,
    fit: BoxFit.cover,
    placeholder: (BuildContext context, String url) => Image.asset(
      Utils.getImgPath(defaultImagePath ?? commonConfig.defaultImgRes),
      width: width,
      height: height,
      fit: BoxFit.cover,
    ),
    errorWidget: (BuildContext context, String url, dynamic error) =>
        Image.asset(
      Utils.getImgPath(defaultImagePath ?? commonConfig.defaultImgRes),
      width: width,
      height: height,
      fit: BoxFit.cover,
    ),
  );
}