clearCache method

Future<void> clearCache()

Removes the underlying cache files. It is an error to clear the cache while a download is in progress.

Implementation

Future<void> clearCache() async {
  if (_downloading) {
    throw Exception("Cannot clear cache while download is in progress");
  }
  _response = null;
  final cacheFile = await this.cacheFile;
  if (await cacheFile.exists()) {
    await cacheFile.delete();
  }
  final mimeFile = await _mimeFile;
  if (await mimeFile.exists()) {
    await mimeFile.delete();
  }
  _progress = 0;
  _downloadProgressSubject.add(0.0);
}