2

In a Flutter app I would like to implement a cache for resources (images, videos,...) that are hosted online.

I would expect it to work on native platforms (Android/iOS) (e.g using the filesystem) and also on the web (e.g using IndexedDB).

Flutter Cache Manager doesn't work on the web. And dart:indexed_db doesn't work on Android/iOS.

Is there any plugin that would be suitable for that purpose ?

5
  • Would these serve your purpose? simple_cache or flutter_cached Commented Dec 23, 2019 at 13:56
  • @Benjamin Does flutter_cached actually handle cache persistence ? It seems that you actually need to implement it yourself. Commented Dec 23, 2019 at 14:15
  • 1
    Implementing it wouldn't hurt, especially with a plugin like localstorage. I think it's the best you're going to get if you want multiplatform compatibility. Commented Dec 23, 2019 at 14:17
  • @Benjamin localstorage seems to fit my need. Do you know how it stores data on Android ? Commented Dec 23, 2019 at 14:43
  • Looking at the source, it seems to do it just by creating a file with dart:io. Commented Dec 23, 2019 at 14:51

1 Answer 1

1

I finally implemented this cache using async_resource library, using ServiceWorkerResource on the Web and HttpNetworkResource + FileResource on native platforms.

Sign up to request clarification or add additional context in comments.

1 Comment

hi, could you share your implementation?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.