Programming question & answer

How do i make CachedNetwork image as rounded circle in flutter?

RRTutors community answer Published Nov 29, 2021

Answer

To load images in flutter we will use CachedNetworkImage widget, this will cache the image and load it from cache if the image already cached otherwise it will load from network.

So how we can add round shape for this cachedNetworkImage

To make round shape we will use imageBuilder property then add shape using the container widget.

CachedNetworkImage(
  imageBuilder: (context, imageProvider) => Container(
    height: 60.h,
    width: 60.h,
    decoration: BoxDecoration(
      borderRadius: BorderRadius.all(Radius.circular(50)),
      image: DecorationImage(
        image: imageProvider,
        fit: BoxFit.cover,
      ),
    ),
  ),
  progressIndicatorBuilder: (context, url, progress) => Center(
    child: CircularProgressIndicator(
      value: progress.progress,
    ),
  ),
  imageUrl:"",
)
Rounded CacheNetwork Image flutter