Baseflow / Baseflow/flutter_cache_manager

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

Offen
#325 18 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Dart
Sterne
809
Forks
510
Ø Merge
6 Min.
Gemergte PRs (30 T.)
1

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start by tracing the imports and exports of path_provider, file, and sqflite through cache_info_repositories/cache_info_repositories.dart and the config_*.dart files. Review the linked #321 discussion and the checklist, then determine how conditional imports and cross-platform cache-info storage should cover web and non-web platforms. Done means platform-dependent libraries are isolated and the package supports web according to the stated goal.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
dart, flutter
Bereich
mobile-dev
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.