HiveCacheStore constructor

HiveCacheStore(
  1. String? directory, {
  2. String hiveBoxName = 'dio_cache',
  3. HiveCipher? encryptionCipher,
})

Initialize cache store by giving Hive a home directory. directory can be null only on web platform or if you already use Hive in your app.

Implementation

HiveCacheStore(
  String? directory, {
  this.hiveBoxName = 'dio_cache',
  this.encryptionCipher,
}) {
  if (directory != null) {
    Hive.init(directory);
  }

  if (!Hive.isAdapterRegistered(_CacheResponseAdapter._typeId)) {
    Hive.registerAdapter(_CacheResponseAdapter());
  }
  if (!Hive.isAdapterRegistered(_CacheControlAdapter._typeId)) {
    Hive.registerAdapter(_CacheControlAdapter());
  }
  if (!Hive.isAdapterRegistered(_CachePriorityAdapter._typeId)) {
    Hive.registerAdapter(_CachePriorityAdapter());
  }

  clean(staleOnly: true);
}