-
-
Notifications
You must be signed in to change notification settings - Fork 275
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
Picture cache for slow connectivity / offline #413
Comments
Are you planning to add the pictures to the database, otherwise there is a great package for exactly that: https://pub.dev/packages/cached_network_image |
No plans for the moment, just the initial idea. |
Then I can take care of it 👍🏻 |
Yes you can! I'm a bit dubious about the package you mentioned though:
|
@monsieurtanuki I just noticed this ticket due to the mention. I can comment on your points.
I thought it was a good idea at first, but for Windows and Linux I implemented a json file which is completely loaded into memory, so it's way faster. However, for the other platforms I still need to switch the default and make sure the existing data is migrated.
At first this was 1 package, but I got a lot of demands for caching other stuff than images, so I decided to extract the caching mechanism into a separate package for those users. So the cache manager is specifically made for CachedNetworkImage, not the other way around.
This package needs improvements on checking the remaining storage on the device. Currently you can only configure the number of items in the cache. The files that have not been used for the longest time are removed when the cache becomes too big. You can also set the maximum age of a cache file, for example remove files if you don't use them for a week. You can also completely clear the cache in 1 call if you want. So you can create your own CacheManager with custom settings and supply that to CachedNetworkImage. |
Thank you @renefloor for your answers! But beyond that the two aspects that would potentially bother me are
|
Yes indeed, we already have the interface, the sqflite implementation, the json implementation and even the migrate function. So we'll only have to make sure this is somehow executed by default when it is not migrated yet.
This is indeed not that hard and on my backlog, but I have to do it in my free time, so even things that are not too hard will be postponed when I'm busy with other stuff. |
The tricky part is "make sure this is somehow executed by default", right? |
Yeah true. But I also kind of want to get rid of the sqflite implementation in the code and move it to a separate package, so I want to make it as easy and clear as possible. But that is indeed the tricky part. |
Hi everyone, |
Hi @bhattabhi013! Your package looks very expensive: just one of its dependencies (flutter_cache_manager) needs clock, collection, file, flutter, http, path, path_provider, pedantic, rxdart, sqflite, uuid. I think it would be feasible without all that fuss, given that the product image url are kind of formatted:
What do you think about that huge simplification? |
…t also for #413 (short living) (#1600) * Files cache * Support for both long & short living caches * Update packages/smooth_app/lib/cache/files/files_cache.dart Co-authored-by: Marvin M <39344769+M123-dev@users.noreply.github.com> * Change for the name of the cache * Non nullable cache name * Introduce some APIs changes as suggested by monsieurtanuki * Change of the subdirectory name * Only two caches are available in the app: temporary & persistent * Some changes * A few more doc * Fix wrong import in tests Co-authored-by: Marvin M <39344769+M123-dev@users.noreply.github.com>
@monsieurtanuki I believe we can close this one ? |
@teolemon As far as I know, no we can't. The idea here is to cache product pictures that we display and download, so that we get a picture even with no/limited connectivity next time. What is implemented is the background upload of edited pictures, with transient local pictures. Not the same thing. |
What
Part of
Screenshots
The text was updated successfully, but these errors were encountered: