Skip to content

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

@sidrao2006

Description

@sidrao2006

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

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

  • Implement file_system for the web using IndexedDB to store the files #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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions