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 · 1 comment

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(),
      ),
    ),
  );
}
@nuxwork
Copy link

nuxwork commented Dec 13, 2024

Are we same question?
I have a picture 10240x5760 , it is too big to display , so i set memCacheWidth to 1920x1080
android display ok, but ios display scaled and fuzzy

Version: cached_network_image: ^3.4.1

    return CachedNetworkImage(
      fit: BoxFit.contain,
      imageUrl: g.s3Url!,
      cacheKey: g.fileCacheKey!,
      memCacheWidth: 1920,
      memCacheHeight: 1080,
      fadeInDuration: const Duration(seconds: 0),
      fadeOutDuration: const Duration(seconds: 0),
      cacheManager: T_LocalCacheManager(),
);

30cb567551e7cae4c8422c7993a717ba

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

2 participants