Comments (9)
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.
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.
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.
Had the same issue. Above fix is a good solution. When do you think you will publish it?
from flutter_cache_manager.
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.
@renefloor I did some testing and 0.4.1 is certainly an improvement, but there are some remaining issues.
- With wifi turned ON, open a view with a list of images where some are off screen.
- Turn wifi OFF.
- Scroll down so images that were off screen are now visible.
- 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.
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.
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.
Hello, is there any update regarding this problem?
from flutter_cache_manager.
Related Issues (20)
- CacheManager attempts to create file named guid.* on Windows (full example included and clear description)
- Cached file should be removed on 404, and error should be added to Stream even if a cached file exists
- If image (DOES NOT EXIST) AND (maxWidth/maxHeight) ARE set, the stream never closes
- How to customize the file name
- How can I get the total size of the cache or get the cache path? HOT 9
- Windows fail
- Auto Extend the cached file's longevity if the user views it before it expired.
- The cached files aren't being removed after the stale duration is over! HOT 1
- ClientException: Redirect limit exceeded
- JsonCacheInfoRepository: FormatException: Unexpected end of input (at character 1) ^
- Privacy manifest file for iOS is missing HOT 2
- Stale period not working properly
- Add option to not use SQLite and default to that HOT 3
- v3.3.1 DefaultCacheManager().getSingleFile(url) throws and pauses the app in debug mode, rather than let the error be caught
- Cannot upgrade rxdart to latest HOT 1
- Invalid argument(s): No host specified in URI. Error thrown . HOT 1
- FormatException was thrown
- Proposal to support all platforms (including web) while emulating browser caching behavior HOT 3
- Provide response body for status code 400
- Platform is not supported after migrating to WASM HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_cache_manager.