From 4a3be03b6be3cd748d06796b0fb05cbdc4ffa298 Mon Sep 17 00:00:00 2001 From: liasica Date: Sun, 10 Mar 2024 11:55:22 +0800 Subject: [PATCH 1/2] get cache total size --- flutter_cache_manager/lib/src/cache_store.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/flutter_cache_manager/lib/src/cache_store.dart b/flutter_cache_manager/lib/src/cache_store.dart index cb90ae2d..670c30cd 100644 --- a/flutter_cache_manager/lib/src/cache_store.dart +++ b/flutter_cache_manager/lib/src/cache_store.dart @@ -202,4 +202,15 @@ class CacheStore { final provider = await _cacheInfoRepository; await provider.close(); } + + + Future getCacheSize() async { + final provider = await _cacheInfoRepository; + final allObjects = await provider.getAllObjects(); + int total = 0; + for (var cacheObject in allObjects) { + total += cacheObject.length ?? 0; + } + return total; + } } From ba41d3cf784d165172643e1de92bdb97203a6933 Mon Sep 17 00:00:00 2001 From: Martijn van Dijk Date: Wed, 31 Jul 2024 22:30:19 +0200 Subject: [PATCH 2/2] Format --- flutter_cache_manager/lib/src/cache_store.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/flutter_cache_manager/lib/src/cache_store.dart b/flutter_cache_manager/lib/src/cache_store.dart index 670c30cd..3ad735ac 100644 --- a/flutter_cache_manager/lib/src/cache_store.dart +++ b/flutter_cache_manager/lib/src/cache_store.dart @@ -203,7 +203,6 @@ class CacheStore { await provider.close(); } - Future getCacheSize() async { final provider = await _cacheInfoRepository; final allObjects = await provider.getAllObjects();