Baseflow / Baseflow/flutter_cache_manager

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

Đang mở
#325 18 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Dart
Star
809
Fork
510
Merge trung bình
6 phút
Pull request đã merge (30 ngày)
1

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu bằng cách lần theo các import và export của path_provider, file và sqflite qua cache_info_repositories/cache_info_repositories.dart cùng các tệp config_*.dart. Xem lại thảo luận được liên kết #321 và checklist, sau đó xác định cách các import có điều kiện và việc lưu trữ thông tin bộ nhớ đệm đa nền tảng nên hỗ trợ các nền tảng web và không phải web. Được xem là hoàn thành khi các thư viện phụ thuộc nền tảng được cô lập và package hỗ trợ web theo mục tiêu đã nêu.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
dart, flutter
Lĩnh vực
mobile-dev
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
30/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.