Baseflow / Baseflow/flutter_cache_manager

Isolate imports and conditionally import libraries to make package platform-independent

未关闭
#325 18 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Dart
星标
809
派生
510
平均合并
6 分钟
30 天内合并 PR
1

描述

## 🏗 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

贡献指南

打开贡献指南

调研方向

首先,通过 cache_info_repositories/cache_info_repositories.dart 和 config_*.dart 文件追踪 path_provider、file 和 sqflite 的导入与导出。查看链接的 #321 讨论和检查清单,然后确定条件导入和跨平台缓存信息存储应如何覆盖 web 和非 web 平台。平台相关库已隔离,并且 package 按照所述目标支持 web,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
dart, flutter
领域
mobile-dev
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
30/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。