llfbandit / dio_cache_interceptor

Dio HTTP cache interceptor with multiple stores respecting HTTP directives (ETag, Last-Modified, Cache-Control) with options.
https://pub.dev/packages/dio_cache_interceptor
120 stars 70 forks source link

Not working on web #138

Closed cavin-7span closed 11 months ago

cavin-7span commented 1 year ago

I have added this package to cache API calls but it seems that this is not working for web since Flutter web doesn't allows us to use path_provider. Here's my implementation that I'm using right now:

final dir = await getTemporaryDirectory();
      final options = CacheOptions(
        store: HiveCacheStore(dir.path),
        hitCacheOnErrorExcept: [401, 403],
      );

      /// Adding caching interceptor for request
      dio.interceptors.add(DioCacheInterceptor(options: options));
cmengler commented 1 year ago

For web, set the directory to null as it's not applicable -- e.g. HiveCacheStore(null);

jaredsburrows commented 10 months ago

@cavin-7span @cmengler So Hive works on flutter for web? What about IsarCacheStore? It only takes a non null String.