clip static method

Widget clip({
  1. String? url,
  2. String? cacheKey,
  3. String? cacheTag,
  4. Widget? placeholder,
  5. ValueChanged<ImageInfo?>? imageCompletionHandler,
  6. Widget? errorWidget,
  7. double? width,
  8. double? height,
  9. BoxFit? fit,
  10. int retries = 3,
  11. Duration? timeLimit,
  12. Map<String, String>? headers,
  13. double? borderRadius,
  14. Color? placeholderColor,
  15. bool round = false,
})

Implementation

static Widget clip({
  String? url,
  String? cacheKey,
  String? cacheTag,
  Widget? placeholder,
  ValueChanged<ImageInfo?>? imageCompletionHandler,
  Widget? errorWidget,
  double? width,
  double? height,
  BoxFit? fit,
  int retries = 3,
  Duration? timeLimit,
  Map<String, String>? headers,
  double? borderRadius,
  Color? placeholderColor,
  bool round = false,
}) {
  Widget image() {
    Widget colorWidget() {
      return placeholder ??
          Container(
            width: width,
            height: height,
            color: placeholderColor ?? baseWebImageDefaultPlaceholderColor,
          );
    }

    return Container(
      width: width,
      height: height,
      color: placeholder == null
          ? (placeholderColor ?? baseWebImageDefaultPlaceholderColor)
          : null,
      child: BaseWebImage(
        url,
        cacheKey: cacheKey,
        cacheTag: cacheTag,
        fit: fit,
        retries: retries,
        timeLimit: timeLimit,
        headers: headers,
        placeholder: placeholder ?? colorWidget(),
        errorWidget: errorWidget ?? colorWidget(),
        imageCompletionHandler: imageCompletionHandler,
      ),
    );
  }

  if (round || borderRadius != null) {
    return ClipRRect(
      borderRadius: BorderRadius.circular(
        (round && width != null) ? width * 0.5 : (borderRadius ?? 0),
      ),
      child: image(),
    );
  }
  return image();
}