flutter_cache_manager icon indicating copy to clipboard operation
flutter_cache_manager copied to clipboard

Whether returned file is from cache or just downloaded

Open xJon opened this issue 4 years ago • 3 comments

💬 Questions and Help

Hi, is there an easy way to check during .getSingleFile() whether the returned file was pulled from the cache, or whether it was just downloaded? Thank you!

xJon avatar Mar 09 '21 20:03 xJon

@xJon no way to check file source u need to change the impl in method getSingleFile to change the return type from File to FileInfo

be know this will make breaking changes

u can make a fork from the package and use it

https://github.com/Baseflow/flutter_cache_manager/blob/3bd49b866d9b5e6ce09d2283f0ef97488be97e1d/flutter_cache_manager/lib/src/cache_manager.dart#L74

binSaed avatar Mar 31 '21 11:03 binSaed

@renefloor why doesn't getSingleFile return FileInfo? Shouldn't it do so to match other methods?

sidrao2006 avatar Apr 09 '21 04:04 sidrao2006

I think that makes more sense indeed, but it will be a breaking change.

You can also do something like this:

    var fileInfo = await DefaultCacheManager()
        .getFileStream(url)
        .first as
    FileInfo;

renefloor avatar Apr 30 '21 13:04 renefloor