AppFlowy/frontend/appflowy_flutter/lib/shared/custom_image_cache_manager.dart
Lucas.Xu 8944edf75f
feat: support clearing caches and fix unable to load image (#4809)
* feat: support clearing caches

* fix: try to clear the image cache when loading failed.

* feat: clear cache on mobile

* chore: add error log
2024-03-04 12:24:25 +08:00

27 lines
760 B
Dart

import 'package:appflowy/shared/appflowy_cache_manager.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
class CustomImageCacheManager extends CacheManager
with ImageCacheManager
implements ICache {
CustomImageCacheManager._() : super(Config(key));
factory CustomImageCacheManager() => _instance;
static final CustomImageCacheManager _instance = CustomImageCacheManager._();
static const key = 'appflowy_image_cache';
@override
Future<int> cacheSize() async {
// https://github.com/Baseflow/flutter_cache_manager/issues/239#issuecomment-719475429
// this package does not provide a way to get the cache size
return 0;
}
@override
Future<void> clearAll() async {
await emptyCache();
}
}