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? cacheWidth,
  11. int? cacheHeight,
  12. int retries = 3,
  13. Duration? timeLimit,
  14. Map<String, String>? headers,
  15. double? borderRadius,
  16. BoxBorder? border,
  17. Color? placeholderColor,
  18. 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? cacheWidth,
  int? cacheHeight,
  int retries = 3,
  Duration? timeLimit,
  Map<String, String>? headers,
  double? borderRadius,
  BoxBorder? border,
  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,
      clipBehavior: Clip.antiAlias,
      decoration: BoxDecoration(
        color: placeholder == null
            ? (placeholderColor ?? baseWebImageDefaultPlaceholderColor)
            : null,
        borderRadius:
            borderRadius != null ? BorderRadius.circular(borderRadius) : null,
      ),
      child: BaseWebImage(
        url,
        cacheKey: cacheKey,
        cacheTag: cacheTag,
        width: width,
        height: height,
        fit: fit,
        cacheWidth: cacheWidth,
        cacheHeight: cacheHeight,
        retries: retries,
        timeLimit: timeLimit,
        headers: headers,
        placeholder: placeholder ?? colorWidget(),
        errorWidget: errorWidget ?? colorWidget(),
        imageCompletionHandler: imageCompletionHandler,
      ),
    );
  }

  if (round || borderRadius != null) {
    return Container(
      clipBehavior: Clip.antiAlias,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(
          (round && width != null) ? width * 0.5 : (borderRadius ?? 0),
        ),
        border: border,
      ),
      child: image(),
    );
  }
  return image();
}