file_storage 1.1.0 copy "file_storage: ^1.1.0" to clipboard
file_storage: ^1.1.0 copied to clipboard

Cross-platform file storage.

This is a simple cross-platform package to operate files in available on a certain platform destinations. Uses idb_shim under the web platform.

Features #

  • Provides with destinations of
    • Application's files,
    • Documents,
    • Cache files.
  • Recursive creation of folders inside supported destinations.
  • Checking existence of a certain file by its path.
  • Loading and saving of
    • binary data (List<int>),
    • text (utf8-encoded),
    • json objects and arrays.
  • Saving stream of data (List<int>).

Usage #

final fileStorage = FileStorage();
final documentsPath = await fileStorage.getDocumentsPath();
final filePath = '$documentsPath/my_folder/my_file.txt';
await fileStorage.ensurePathExists(fileName);
await fileStorage.saveText(fileName, 'My text');
final savedText = await fileStorage.loadText(fileName);
print('Saved text is: $savedText');
final bytes1 = Uint8List.fromList([ 1, 2, 3 ]);
final bytes2 = Uint8List.fromList([ 4, 5, 6 ]);
await fileStorage.saveStream(fileName, Stream.fromIterable([
  bytes1, bytes2
]));

DevTools extension #

The package ships with a Flutter DevTools extension that lets you explore, edit, and delete stored files while debugging. Register the service extensions during development to enable the bridge between your app and the DevTools UI:

import 'package:file_storage/file_storage.dart';

void main() {
  assert(() {
    registerFileStorageDevTools();
    return true;
  }());
  runApp(const MyApp());
}

Make sure your pubspec.yaml contains this:

devtools:
   extensions:
      - file_storage

If the devtools extension doesn't show up, make sure that there's a devtools_options.yaml file in the root of your project with this content:

extensions:
  - file_storage: true

Whenever you change the extension UI, rebuild the static assets before publishing the package:

dart run devtools_extensions build_and_copy \
    --source=extension/file_storage_devtools_extension \
    --dest=extension/devtools
2
likes
140
points
104
downloads

Publisher

verified publisherrightbrain.pro

Weekly Downloads

Cross-platform file storage.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, idb_shim, path, path_provider

More

Packages that depend on file_storage