Baseflow / Baseflow/flutter_cache_manager
Isolate imports and conditionally import libraries to make package platform-independent
- Dominant language
- Dart
- Stars
- 809
- Forks
- 510
- Avg merge
- 6m
- Merged PRs (30d)
- 1
Description
## 🏗 Enhancement Proposal
Currently `flutter_cache_manager` is platform-independent, yet according to pub.dev, the package doesn't support web. This can be solved using conditionally importing `dart:io` dependent libraries.
`path_provider`, `file` and `sqflite` are platform-dependent and must only be imported/exported in *_io.dart files which will then be conditionally imported/exported.
`file` can be replaced with `cross_file` (as mentioned in [#321 (comment)](https://github.com/Baseflow/flutter_cache_manager/pull/321#issuecomment-854064553))
`path_provider` and `sqflite` are rather easy to isolate since they are imported only in cache_info_repositories which are selectively imported in config_*.dart files. The only problem is that `cache_info_repositories/cache_info_repositories.dart` is exported. @renefloor what can we do about this?
### Pitch
This will increase pub points which affect discoverability. Also, partially platform-dependent code will be separated and be easier to maintain.
### Checklist
- [ ] #339
- [ ] Store the config json data as a file on all platforms except the web, where web storage will be used to store this data
- [ ] Make the JSON implementation of cache info repository platform independent
- [ ] Migrate all instances to use the new JSON implementation
- [ ] If necessary, replace platform dependent dependencies with cross-platform implementations
Contributor guide
Assessment
This issue has not been assessed yet.