clip static method
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,
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();
}