Skip to content

Commit 4a3be03

Browse files
liasicamartijn00
authored andcommitted
get cache total size
1 parent a1b4955 commit 4a3be03

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

flutter_cache_manager/lib/src/cache_store.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,15 @@ class CacheStore {
202202
final provider = await _cacheInfoRepository;
203203
await provider.close();
204204
}
205+
206+
207+
Future<int> getCacheSize() async {
208+
final provider = await _cacheInfoRepository;
209+
final allObjects = await provider.getAllObjects();
210+
int total = 0;
211+
for (var cacheObject in allObjects) {
212+
total += cacheObject.length ?? 0;
213+
}
214+
return total;
215+
}
205216
}

0 commit comments

Comments
 (0)