CachedNetwokImage - Resize image before rendering

Viewed 244

I am making an app that displays a lot of images. I am using CachedNetworkImage for this. The problem is that when I display these images the framerate is really bad. I wanted to resize those images before displaying them so that I reduce the jank.

I found out about these properties while looking around, maxHeightDiskCache and memCacheHeight. Setting maxHeightDiskCache achieved what I wanted but it also resized the image in cache storage which I did not want. memCacheHeight seemed to be what I wanted from reading the description. But setting memCacheHeight didn't seem to work, the images were displayed with their original resolution.

This is my code:


CachedNetworkImage(
                memCacheHeight: 400,
                memCacheWidth: 200,
                imageUrl: ctrlr.images[index].url,
                imageBuilder: (context, imageProvider) {
                  return ImageChip(
                    imageProvider: imageProvider
                  );
                },
                placeholder: (context, url) => Center(
                    child: Container(
                  height: SizeConfig.safeBlockHorizontal * 8,
                  width: SizeConfig.safeBlockHorizontal * 8,
                  child: CircularProgressIndicator(),
                )),
                errorWidget: (context, url, error) => Icon(Icons.error),
              )

What am I doing wrong?

0 Answers
Related