Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yvone1991 opened this issue Sep 3, 2024 · 0 comments
Open

Comments

@yvone1991
Copy link

yvone1991 commented Sep 3, 2024

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(),
      ),
    ),
  );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant