Skip to content

Using memCache to cache images makes the fit configuration ineffective. #969

Open
@yvone1991

Description

@yvone1991

Expected behavior

The images should not reload when scrolling through the list and the fit configuration should work properly even when using memCache for caching.

Reproduction steps

Use version cached_network_image: ^3.4.1.
The app is on a multi-platform including iOS and Android.
The server returns high-definition image addresses. When scrolling through a Flutter list and an image goes off-screen and then comes back into view, the already loaded image reloads.
Try to use memCache to configure caching, but after caching, the fit configuration for images of different sizes does not take effect, resulting in the image being stretched.

Configuration

Version: cached_network_image: ^3.4.1

Widget netWorkImage(String url,
    {double? width,
    double? height,
    double? radius,
    int? memCacheWidth,
    int? memCacheHeight,
    BoxFit fit = BoxFit.cover,
    Function()? onPressed}) {
  return PressOpacity(
    onPressed: onPressed,
    child: ClipRRect(
      borderRadius: BorderRadius.circular(radius ?? 0),
      child: CachedNetworkImage(
        width: width,
        height: height,
        memCacheWidth: memCacheWidth,
        memCacheHeight: memCacheHeight,
        fit: fit,
        imageUrl: url,
        placeholder: (context, url) => loadingPlaceHolder(),
      ),
    ),
  );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions