build method
Widget
Implementation
@override
Widget build(BuildContext context) {
return Box(
width: width,
height: height,
padding: padding,
margin: margin,
color: backgroundColor,
isCircle: isCircle,
radius: radius,
border: border,
boxShadows: boxShadows,
gradient: gradient,
constraints: constraints,
child: Builder(
builder: (context) {
switch (type) {
case ImageType.asset:
return Image.asset(
imageSrc,
width: width,
height: height,
fit: fit,
color: imageColor,
centerSlice: centerSlice,
errorBuilder: (context, error, stackTrace) {
return this.error == null ? SizedBox.shrink() : this.error!;
},
);
case ImageType.svg:
return SvgPicture.asset(
imageSrc,
width: width,
height: height,
fit: fit,
colorFilter: imageColor == null
? null
: ColorFilter.mode(imageColor!, BlendMode.srcIn),
errorBuilder: (context, error, stackTrace) {
return this.error == null ? const SizedBox.shrink() : this.error!;
},
);
case ImageType.network:
return CachedNetworkImage(
imageUrl: imageSrc,
fit: fit,
color: imageColor,
placeholder: placeholder == null ? null : (context, url) => placeholder!,
errorWidget: (context, url, error) =>
(this.error == null ? const SizedBox.shrink() : this.error!),
);
case ImageType.file:
return Image.file(
File(imageSrc),
width: width,
height: height,
fit: fit,
color: imageColor,
centerSlice: centerSlice,
errorBuilder: (context, error, stackTrace) {
return this.error == null ? const SizedBox.shrink() : this.error!;
},
);
}
},
),
);
}