toJPGImage method

Widget toJPGImage({
  1. double? width,
  2. double? height,
  3. double? square,
  4. BoxFit? fit,
  5. BorderRadius? borderRadius,
  6. bool isNetwork = false,
})

Implementation

Widget toJPGImage({
  double? width,
  double? height,
  double? square,
  BoxFit? fit,
  BorderRadius? borderRadius,
  bool isNetwork = false,
}) =>
    ClipRRect(
      clipBehavior: borderRadius != null ? Clip.hardEdge : Clip.none,
      borderRadius: borderRadius ?? BorderRadius.zero,
      child: isNetwork
          ? CachedNetworkImage(
              imageUrl: this,
              placeholder: (context, url) =>
                  const Icon(Icons.image, color: Colors.white, size: 30),
              errorWidget: (context, url, error) =>
                  const Icon(Icons.error, color: Colors.white, size: 30),
              width: square ?? width,
              height: square ?? height,
              fit: fit ?? BoxFit.cover,
              maxWidthDiskCache: GlobalConfig.networkImageCachedWidth,
              maxHeightDiskCache: GlobalConfig.networkImageCachedHeight)
          : Image.asset(
              'assets/images/$this',
              width: square ?? width,
              height: square ?? height,
              fit: fit ?? BoxFit.cover,
            ),
    );