kimage function
图片
isNet
是否网络图片
url
图片url或者本地图片路径path
width
图片宽度
height
图片高度
radius
图片圆角
errorPath
错误图片路径
fit
填充方式
Implementation
Widget kimage(
bool isNet,
String? url,
int? width,
int? height, {
int? radius,
String? errorPath,
BoxFit fit = BoxFit.cover,
}) {
if (url == null || url.kisBlank()) {
return _imageRadius(errorPath, width, height, radius: radius, fit: fit);
}
if (isNet) {
if (radius == null) {
return CachedNetworkImage(
imageUrl: url,
// placeholder: (context, url) => const CircularProgressIndicator(),
errorWidget: (context, url, error) =>
_imageRadius(errorPath, width, height, radius: radius),
height: height?.h,
width: width?.w,
fit: fit,
);
} else {
return CachedNetworkImage(
imageUrl: url,
imageBuilder: (context, image) => ClipRRect(
borderRadius: BorderRadius.circular(radius.r),
child: Image(
image: image,
height: height?.h,
width: height?.w,
fit: fit,
),
),
// placeholder: (context, url) => const CircularProgressIndicator(),
errorWidget: (context, url, error) =>
_imageRadius(errorPath, width, height, radius: radius),
height: height?.h,
width: width?.w,
);
}
} else {
return _imageRadius(url, width, height, radius: radius);
}
}