Baseflow / flutter_cache_manager

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

Update cache_manager.dart #341

Closed Fnalsk closed 2 years ago

Fnalsk commented 2 years ago

make getSingleFile nullable

:sparkles: What kind of change does this PR introduce? (Bug fix, feature, docs update...)

allows getSingleFile to return a nullable object

:arrow_heading_down: What is the current behavior?

the function cannot return a nullable.

:new: What is the new behavior (if this is a feature change)?

If a file from a url is not available for whatever reason (maybe the file was deleted from the server), we should be able to use the onError function to return null. currently we can only return null if we await the file future, which can be slow.

:boom: Does this PR introduce a breaking change?

no

:thinking: Checklist before submitting

renefloor commented 2 years ago

I don't understand what this would change. This just makes the result nullable, but the function doesn't change, so it will never return null. At the moment it gives a catchable error when download fails, so I guess we would need to change that, but that's a breaking change.

we should be able to use the onError function to return null. currently we can only return null if we await the file future, which can be slow

The error can only come after the download failed, so I don't know how anything can be made faster.

Fnalsk commented 2 years ago

Honestly it was just really late in the day and there was something wrong with the app that I thought for some reason this would fix. I ended up fixing the issue with a pretty trivial method the next day, but forgot I had made this pr. Feel free to close and delete.

Sorry for the trouble!

On Wed., Oct. 27, 2021, 12:36 a.m. Rene Floor, @.***> wrote:

I don't understand what this would change. This just makes the result nullable, but the function doesn't change, so it will never return null. At the moment it gives a catchable error when download fails, so I guess we would need to change that, but that's a breaking change.

we should be able to use the onError function to return null. currently we can only return null if we await the file future, which can be slow

The error can only come after the download failed, so I don't know how anything can be made faster.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Baseflow/flutter_cache_manager/pull/341#issuecomment-952586544, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASFTSHGLTOGWRCTRXHT23MDUI6TXXANCNFSM5GSWAMNA .