Code Monkey home page Code Monkey logo

Comments (9)

nyvelius avatar nyvelius commented on August 16, 2024 1

I haven't looked further into the code, but it seems that null data values shouldn't be cached in the first place -- since there isn't anything to cache. Or as a second resort, such values should be easy to evict. For now I just forked the repo and added a quick workaround so I could keep working.

jsonCache.forEach((key, data) {
  if (data == null) {
    return;
  }
  _cacheData[key] = new CacheObject.fromMap(key, data);

from flutter_cache_manager.

renefloor avatar renefloor commented on August 16, 2024 1

That is indeed a good idea as well. I am aware that checking whether you have an internet connection is impossible to do in general, but a change in the connectivity is a pretty good indicator that there could be a change in internet connection.
Leaving this to the developer gives him/her indeed more options on how this should happen, but I think it is better to do this within the library, at least to a certain point. Maybe we could make a default behaviour and an option to override that.

from flutter_cache_manager.

renefloor avatar renefloor commented on August 16, 2024

Yes, I can imagine this crashes when the map is null

  CacheObject.fromMap(String url, Map map) {
    this.url = url;
    _map = map;

    if (_map.containsKey(_keyTouched)) {
      touched = new DateTime.fromMillisecondsSinceEpoch(_map[_keyTouched]);
    } else {
      touch();
    }

    lock = new Object();
  }

from flutter_cache_manager.

mig35 avatar mig35 commented on August 16, 2024

Had the same issue. Above fix is a good solution. When do you think you will publish it?

from flutter_cache_manager.

renefloor avatar renefloor commented on August 16, 2024

Sorry it took some time, but I wanted to fix it good. The data == null fix was only mitigating the effects of the problem. I just found time to have a good look at it and fixed a couple of problems I found. Can you confirm the problems are solved in 0.4.1?

from flutter_cache_manager.

nyvelius avatar nyvelius commented on August 16, 2024

@renefloor I did some testing and 0.4.1 is certainly an improvement, but there are some remaining issues.

  1. With wifi turned ON, open a view with a list of images where some are off screen.
  2. Turn wifi OFF.
  3. Scroll down so images that were off screen are now visible.
  4. Turn wifi back ON.

Result: The images do not load and will not load even when switching between screens or minimizing and re-opening the app.

Unlike before patch 0.4.1, they will now load if the app is completely closed and reopened.

from flutter_cache_manager.

renefloor avatar renefloor commented on August 16, 2024

Yes true.
I also found that when an image fails to load and then you turn on a data connection you have to do some effort to get it reloaded. I will probably have to keep track of changes in the network connection after an image has failed loading. I will make a separate issue for that in the CachedNetworkImage library.

from flutter_cache_manager.

nyvelius avatar nyvelius commented on August 16, 2024

That could work. There is the connectivity package, but as the authors point out, detecting connectivity can be tricky:

Note that on Android, this does not guarantee connection to Internet. For instance, the app might have wifi access but it might be a VPN or a hotel WiFi with no access.

I don't know much about the internals of Flutter, but would it be possible to force a retry at least when re-opening a screen?

https://pub.dartlang.org/packages/connectivity

Edit: On second thought, maybe some sort of refresh functionality could be left up to the developer using the library? Something along the lines of creating a reference to the image cache and then calling refresh whenever it is appropriate, such as when internet connectivity is detected OR the user pulls down to refresh OR whatever works for that particular app.

from flutter_cache_manager.

marianoarga avatar marianoarga commented on August 16, 2024

Hello, is there any update regarding this problem?

from flutter_cache_manager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.