kimageCircle function

Widget kimageCircle(
  1. bool isNet,
  2. String? url,
  3. int width,
  4. int height, {
  5. String? errorPath,
})

圆形图片 isNet 是否网络图片 url 图片url或者本地图片路径path width 图片宽度 height 图片高度 errorPath 错误图片路径

Implementation

Widget kimageCircle(
  bool isNet,
  String? url,
  int width,
  int height, {
  String? errorPath,
}) {
  if (url == null || url.kisBlank()) {
    return Container(
      decoration: BoxDecoration(
        shape: BoxShape.circle,
        image: DecorationImage(
            image: AssetImage(errorPath ?? UiPlatform.get.getLogoPath()),
            fit: BoxFit.fill),
      ),
    );
  }
  return SizedBox(
    width: height.w,
    height: width.h,
    child: isNet
        ? CachedNetworkImage(
            imageUrl: url,
            imageBuilder: (context, imageProvider) => Container(
              decoration: BoxDecoration(
                shape: BoxShape.circle,
                image: DecorationImage(
                  image: CachedNetworkImageProvider(url),
                  fit: BoxFit.fill,
                ),
              ),
            ),
            placeholder: (context, url) => const CircularProgressIndicator(),
            errorWidget: (context, url, error) => Container(
              decoration: BoxDecoration(
                shape: BoxShape.circle,
                image: DecorationImage(
                    image:
                        AssetImage(errorPath ?? UiPlatform.get.getLogoPath()),
                    fit: BoxFit.fill),
              ),
            ),
          )
        : Container(
            decoration: BoxDecoration(
              shape: BoxShape.circle,
              image: DecorationImage(image: AssetImage(url), fit: BoxFit.fill),
            ),
          ),
  );
}