networkImageContainer method

Widget networkImageContainer({
  1. String? imageUrl,
  2. double? width,
  3. double? height,
})

network image container with radius and size

Implementation

Widget networkImageContainer(
    {String? imageUrl, double? width, double? height}) {
  return Container(
    width: width ?? 55,
    height: height ?? 55,
    decoration: BoxDecoration(
      borderRadius: BorderRadius.circular(height != null ? height / 2 : 27.5),
      border: Border.all(color: Colors.grey),
      color: primaryColor,
    ),
    child: ClipRRect(
      borderRadius: BorderRadius.circular(height != null ? height / 2 : 27.5),
      child: imageUrl == null
          ? Image.asset(
              "assets/images/profile.png",
              width: width ?? 55,
              height: height ?? 55,
            )
          : imageUrl.isNotEmpty
              ? Image.network(
                  imageUrl,
                  width: width ?? 55,
                  height: height ?? 55,
                  loadingBuilder: (context, child, loadingProgress) {
                    if (loadingProgress != null) {
                      return Center(
                        child: CircularProgressIndicator(
                          color: themeColor,
                          strokeWidth: 3,
                        ),
                      );
                    } else {
                      return child;
                    }
                  },
                  errorBuilder: (context, obj, st) {
                    return Image.asset(
                      "assets/images/profile.png",
                      width: width ?? 55,
                      height: height ?? 55,
                    );
                  },
                )
              : Image.asset(
                  "assets/images/profile.png",
                  width: width ?? 55,
                  height: height ?? 55,
                ),
    ),
  );
}