emptyCache method

  1. @override
Future<void> emptyCache()
override

Remove all files from the cache.

Implementation

@override
Future<void> emptyCache() async {
  await _ensureInitialized();

  // Delete all cached files
  for (final key in _cacheBox!.keys.toList()) {
    final raw = _cacheBox!.get(key);
    if (raw != null) {
      final metadata = CacheEntryMetadata.fromMap(raw);
      final file = io.File(_cacheFilePath(metadata.relativePath));
      if (await file.exists()) {
        await file.delete();
      }
    }
  }

  await _cacheBox!.clear();
}