Cross File Manager

Cover - Cross File Manager

GitHub License

Transparent reading of files from Flutter assets, Internet (by URL), zip archives by uploader priority. The easy-to-use package.

Features

We can choose with CrossFileManager the priority for uploaders yourself. For example, if the file is not in the assets, an attempt will be made to get the file from the cloud.

Can develop own loader for download files from Firebase, Firestore, Amazon AWS, Google Drive, Microsoft Azure Cloud Storage, OneDrive, Dropbox, etc. - any data source can be included in the CrossFileManager. See class Loader and already implemented loaders.

Can retrieve the needed file from an archive. It comes in handy when you need to download thousands of small files.

Can memorize a received file and retrieve it from local storage the next time it is requested.

Able to download files in formats:

  • String
  • Image like dart.ui
  • Image like package:flutter/widgets.dart
  • File, binary data

How it works

Direct path to file - CrossFileManager

Getting started

Add this package to pubspec.yaml. See Installing tab above.

Usage

Create a manager for App:

final fm = CrossFileManager.create(
  loaders: const [
    PlainAssetsLoader(),
    ZipAssetsLoader(),
    PlainFileLoader(),
    ZipFileLoader(),
  ],
);

Use the manager in the App:

final String? r = await fm.loadString(path);
import 'dart:ui' as ui;

final ui.Image? r = await fm.loadImageUi(path);
import 'package:flutter/widgets.dart' as widgets;

final widgets.Image? r = await fm.loadImageWidget(path);
final File? r = await fm.loadFile(path);
final bool r = await fm.exists(path);
final bool r = await fm.existsInCache(path);
/// Just add file to cache for fast access in the future.
await fm.warmUp(path);

The manager announced above will search file by path in the local assets, then in the zip archives of local assets, then in the local filesystem, then in the zip archives of local filesystem.

It will return the first file found.

See example/main.dart for more use cases:

Example App with CrossFileManager

Welcome

This package is open-source, stable and well-tested. Development happens on GitHub. Feel free to report issues or create a pull-request there.

General questions are best asked on StackOverflow.

TODO

Libraries

cross_file_manager