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

When returning from background image dissapear #12

Open
aleksandar-radivojevic opened this issue Sep 1, 2022 · 3 comments
Open

When returning from background image dissapear #12

aleksandar-radivojevic opened this issue Sep 1, 2022 · 3 comments

Comments

@aleksandar-radivojevic
Copy link

aleksandar-radivojevic commented Sep 1, 2022

Hey bro, I really love your plugin and I am using it for almost 3 years now. Thank you very much because FadeInImage sucks, and your plugin is way better.

I found a bug where when I return from background, images disappear, please take a look at video. So this images were here and everything was working perfectly but when I put app in background, lock screen and wait for 1 or 2 minutes, and then open again app, images disappear and after some scrolling they appear again.

I tried replacing ImageFade with FadeInImage and this is not happening, images don't disappear with FadeInImage.

FLUTTER DOCTOR:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.5, on macOS 11.6.4 20G417 darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.70.2)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

• No issues found!

TESTED on iPHONE 6s, iOS 15.3.1

Below is my code, so nothing fancy.

Container(
      decoration: BoxDecoration(
        color: Theme.of(context).appBarTheme.backgroundColor,
      ),
      child: ClipRRect(
        borderRadius: const BorderRadius.only(
            topLeft: Radius.circular(5), topRight: Radius.circular(5)),
        child: ImageFade(
          image: NetworkImage(featuredMedia),
          excludeFromSemantics: true,
          placeholder: Image.memory(
            kTransparentImage,
            fit: BoxFit.cover,
          ),
          fit: BoxFit.cover,
          duration: const Duration(milliseconds: 300),
          // fadeInCurve: Curves.easeInOut,
          height: useTabletLayout ? 400 : 220,
          alignment: Alignment.center,
          width: MediaQuery.of(context).size.width,
        ),
      ),
    );
RPReplay_Final1662013878.MP4
@good-good-study
Copy link

mee to !!! , what i do ?

@kitsuniru
Copy link

@gskinner @maks any fix for this?

@kapilsharma-gts
Copy link

kapilsharma-gts commented Sep 17, 2024

I think this will work

import 'package:cached_network_image/cached_network_image.dart';
import 'package:image_fade/image_fade.dart';

ImageFade(
  image: CachedNetworkImageProvider(featuredMedia), // Use CachedNetworkImageProvider
  placeholder: Image.memory(
    kTransparentImage,
    fit: BoxFit.cover,
  ),
  fit: BoxFit.cover,
  duration: const Duration(milliseconds: 300),
  height: useTabletLayout ? 400 : 220,
  alignment: Alignment.center,
  width: MediaQuery.of(context).size.width,
);

Additionally, increase the image cache size:

PaintingBinding.instance.imageCache.maximumSize = 1000; // Number of images
PaintingBinding.instance.imageCache.maximumSizeBytes = 100 * 1024 * 1024; // 100 MB

This should help manage image caching more effectively and prevent issues with disappearing images when returning from the background

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

4 participants