cross_file_manager 0.4.3 cross_file_manager: ^0.4.3 copied to clipboard
Transparent reading of files from assets, Internet (by URL), zip archives by uploader priority.
Cross File Manager #
Transparent reading of files from Flutter assets, Internet (by URL), zip archives by uploader priority.
Features #
We can choose with Cross File Manager
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
likedart.ui
Image
likepackage:flutter/widgets.dart
File
, binary data
How it works #
Direct path to file
Direct path to file with cache
ZIP path to file
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:
License #
TODO #
- Separate the package to work with pure Dart.
- Replace
File
toWFile
. https://pub.dev/packages/wfile