Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #297 清除缓存功能失效 #326

Merged
merged 1 commit into from
Oct 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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