diff --git a/flutter_cache_manager/lib/src/cache_store.dart b/flutter_cache_manager/lib/src/cache_store.dart index 3ad735ac..bf283086 100644 --- a/flutter_cache_manager/lib/src/cache_store.dart +++ b/flutter_cache_manager/lib/src/cache_store.dart @@ -154,9 +154,11 @@ class CacheStore { final provider = await _cacheInfoRepository; final toRemove = []; final allObjects = await provider.getAllObjects(); + var futures = []; for (final cacheObject in allObjects) { - _removeCachedFile(cacheObject, toRemove); + futures.add(_removeCachedFile(cacheObject, toRemove)); } + await Future.wait(futures); await provider.deleteAll(toRemove); } @@ -180,7 +182,7 @@ class CacheStore { _memCache.remove(cacheObject.key); } if (_futureCache.containsKey(cacheObject.key)) { - _futureCache.remove(cacheObject.key); + await _futureCache.remove(cacheObject.key); } final file = io.File(cacheObject.relativePath);