purgeAllCaches static method
Purges all cached files from all caches regardless if the cache is used or not
Implementation
static Future<void> purgeAllCaches() async {
for (FileTileBitmapCache cache in List.from(_instances.values)) {
await cache.purgeAll();
}
_instances.clear();
// now purge every cache not yet active
String rootDir = await FileHelper.getTempDirectory("mapsforgetiles");
List<String> caches = (await FileHelper.getFiles(rootDir));
for (String cache in caches) {
List<String> files = (await FileHelper.getFiles(cache));
for (String file in files) {
try {
await FileHelper.delete(file);
} catch (error) {
// ignore this error
}
}
if (files.length > 0)
_log.info("Deleted ${files.length} files from cache $cache");
}
}