clear method
Clears the cache in the cache directory.
Implementation
Future<void> clear() {
return _mutex.protect(() async {
final Directory? cache = await PlatformUtils.cacheDirectory;
if (cache != null) {
final List<File> files =
hashes.map((e) => File('${cache.path}/$e')).toList();
final List<Future> futures = [];
for (var file in files) {
futures.add(
Future(() async {
try {
await file.delete();
} catch (_) {
// No-op.
}
}),
);
}
await Future.wait(futures);
_updateInfo();
}
});
}