Skip to content

Commit

Permalink
Merge pull request #326 from LeetaoGoooo/fix-empty-cache-failed
Browse files Browse the repository at this point in the history
fix:  #297 清除缓存功能失效
  • Loading branch information
Predidit authored Oct 19, 2024
2 parents 8948b32 + e56cd00 commit bf6f208
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/pages/about/about_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ class _AboutPageState extends State<AboutPage> {
navigationBarState.showNavigate();
}

Future<void> _getCacheSize() async {
Future<Directory> _getCacheDir() async {
Directory tempDir = await getTemporaryDirectory();
Directory cacheDir = Directory('${tempDir.path}/libCachedImageData');
return Directory('${tempDir.path}/libCachedImageData');
}

Future<void> _getCacheSize() async {
Directory cacheDir = await _getCacheDir();

if (await cacheDir.exists()) {
int totalSizeBytes = await _getTotalSizeOfFilesInDir(cacheDir);
Expand Down Expand Up @@ -85,8 +89,8 @@ class _AboutPageState extends State<AboutPage> {
}

Future<void> _clearCache() async {
final cacheManager = DefaultCacheManager();
await cacheManager.emptyCache();
final Directory libCacheDir = await _getCacheDir();
await libCacheDir.delete(recursive: true);
_getCacheSize();
}

Expand Down

0 comments on commit bf6f208

Please sign in to comment.