diff --git a/lib/src/firebase_cache_manager/base_firebase_cache_manager.dart b/lib/src/firebase_cache_manager/base_firebase_cache_manager.dart index 2fd751c..edf36b5 100644 --- a/lib/src/firebase_cache_manager/base_firebase_cache_manager.dart +++ b/lib/src/firebase_cache_manager/base_firebase_cache_manager.dart @@ -8,6 +8,8 @@ abstract class BaseFirebaseCacheManager { BaseFirebaseCacheManager({this.subDir}); + Future isCached(FirebaseUrl firebaseUrl); + /// Fetch, cache and returns the localFilePath for Cloud Storage File. /// /// You need to specify [firebaseUrl] diff --git a/lib/src/firebase_cache_manager/mobile_firebase_cache_manager.dart b/lib/src/firebase_cache_manager/mobile_firebase_cache_manager.dart index c8ef0a0..41d211c 100644 --- a/lib/src/firebase_cache_manager/mobile_firebase_cache_manager.dart +++ b/lib/src/firebase_cache_manager/mobile_firebase_cache_manager.dart @@ -197,4 +197,12 @@ class FirebaseCacheManager extends BaseFirebaseCacheManager { Future getFullLocalPath(String fileName) async { return join(await _cacheDirectoryPath, fileName); } + + @override + Future isCached(FirebaseUrl firebaseUrl) async { + final manager = await _cacheManager; + final cachedObject = await manager.get(firebaseUrl.uniqueId); + + return cachedObject != null; + } } diff --git a/lib/src/firebase_cache_manager/web_firebase_cache_manager.dart b/lib/src/firebase_cache_manager/web_firebase_cache_manager.dart index 99d8639..93e5b37 100644 --- a/lib/src/firebase_cache_manager/web_firebase_cache_manager.dart +++ b/lib/src/firebase_cache_manager/web_firebase_cache_manager.dart @@ -44,4 +44,9 @@ class FirebaseCacheManager extends BaseFirebaseCacheManager { rawData: bytes, ); } + + @override + Future isCached(FirebaseUrl firebaseUrl) { + throw UnsupportedError("Not Supported On Web"); + } }