cross_file_manager 0.3.1 cross_file_manager: ^0.3.1 copied to clipboard
Can read files from assets, Internet (by URL), zip archives by loader priority.
CrossFileManager #
Transparent reading of files wherever they are located: assets, Internet (by URL), zip archives.
Features #
You can choose 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.
You 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 #
A picture is worth a thousand words.
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: