Baseflow / flutter_cache_manager

Generic cache manager for flutter
https://baseflow.com
MIT License
740 stars 429 forks source link

Whether returned file is from cache or just downloaded #296

Open xJon opened 3 years ago

xJon commented 3 years ago

💬 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!

binSaed commented 3 years ago

@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

sidrao2006 commented 3 years ago

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

renefloor commented 3 years ago

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;