clearCache method

Future<void> clearCache()

Clears all cached responses (memory and disk).

Implementation

Future<void> clearCache() async {
  _memoryCache.clear();
  if (_config.cacheDir != null) {
    final dir = Directory(_config.cacheDir!);
    if (await dir.exists()) {
      await for (final entity in dir.list()) {
        if (entity is File && entity.path.endsWith('.cache.json')) {
          await entity.delete();
        }
      }
    }
  }
}