buildImageView method

dynamic buildImageView()

Implementation

buildImageView() {
  if (svgPath != null && svgPath!.isNotEmpty) {
    return SizedBox(
      height: height,
      width: width,
      child: SvgPicture.asset(
        svgPath!,
        height: height,
        width: width,
        fit: fit ?? BoxFit.contain,
        // color: color,
      ),
    );
  } else if (pickerFilePath != null && pickerFilePath!.path.isNotEmpty) {
    return Image.file(
      pickerFilePath!,
      height: height,
      width: width,
      fit: fit ?? BoxFit.cover,
      color: color,
    );
  } else if (url != null && url!.isNotEmpty) {
    return CachedNetworkImage(
      height: height,
      width: width,
      fit: fit,
      imageUrl: url!,
      color: color,
      placeholder: (context, url) => Image.asset(
        placeHolder,
        height: height,
        width: width,
        fit: fit ?? BoxFit.cover,
      ),
      errorWidget: (context, url, error) => Image.asset(
        placeHolder,
        height: height,
        width: width,
        fit: fit ?? BoxFit.cover,
      ),
    );
  } else if (imageAssetPath != null && imageAssetPath!.isNotEmpty) {
    return Image.asset(
      imageAssetPath!,
      height: height,
      width: width,
      fit: fit ?? BoxFit.cover,
      color: color,
    );
  }
  return const SizedBox();
}