filesaverz 2.1.0 copy "filesaverz: ^2.1.0" to clipboard
filesaverz: ^2.1.0 copied to clipboard

outdated

A package that makes it easy for user to browse folder and save file or pick files in android.

File Saver Z #

FileSaverZ Version
A package that makes it easy for user to browse folder and save file or pick files in android.

Preview #

Install #

Add this to your dependency

dependencies:
  filesaverz: ^2.1.0

Continue by adding permission in your AndroidManifest.xml.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.example">
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

And then import the filesaver (with z) package.

import 'package:filesaverz/filesaverz.dart';

Usage #

First, setting up the FileSaver widget like this.

  FileSaver fileSaver = FileSaver(
  fileTypes: const ['txt','pdf'],
  initialFileName: 'Untitled File',
);

or this customable FileSaver.

FileSaver fileSaver = FileSaver.builder(
   fileTypes: const ['txt','pdf'],
   initialFileName: 'Untitled File',
   headerBuilder: (context, state) => /* Your Widget */,
   bodyBuilder: (context, state) => /* Your Widget */,
   footerBuilder: (context, state) => /* Your Widget */,
);

And then in async function call these:

Purpose Code
Getting selected path from saving file.
String? path = await fileSaver.getPath(context);
Calling writeAsBytes method.
fileSaver.writeAsBytes(bytes, context: context);
Calling writeAsBytesSync method.
fileSaver.writeAsBytesSync(bytes, context: context);
Calling writeAsString method.
fileSaver.writeAsString(contents, context: context);
Calling writeAsStringSync method.
fileSaver.writeAsStringSync(contents, context: context);
Picking single file.
File? file = await fileSaver.pickFile(context);
Picking multiple files.
List<File>? files = await fileSaver.pickFiles(context);

Documentation #

Property Code
headerBuilder, an optional builder.

(context, state) {
  return Text('My Custom Header Widget');
},
      
bodyBuilder, an optional builder.

(context, state) {
  return Text('My Custom Body Widget');
},
      
footerBuilder, an optional builder

(context, state) {
  return Text('My Custom Footer Widget');
},
      
style, set custom Color, TextStyle and Icon

FileSaverStyle(
  primaryColor: Colors.blue,
  secondaryColor: Colors.white,
  primaryTextStyle: TextStyle(),
  secondaryTextStyle: TextStyle(),
  icons: [
    FileSaverIcon(icon: (path) => Icon(Icons.default)),
    FileSaverIcon.directory(icon: (path) => Icon(Icons.folder)),
    FileSaverIcon.file(fileType: 'jpg', icon: (path) => Image.file(File(path)),
    ]
),
      
initialFileName, this property is used when you call saving method.

'Untitled File',
      
initialDirectory, in Android by default it's calling Environment.getExternalStorageDirectory.

Directory('Storage Path'),
      
fileTypes, in saving method this fileTypes used as an option for user to set the desired fileTypes to write. But in picking file method. this property is used to limit what kind of fileTypes that we want to display.

const ['jpg','gif','png'],
      

Full Documentation here.

Example #

17
likes
0
pub points
54%
popularity

Publisher

verified publisherinidia.app

A package that makes it easy for user to browse folder and save file or pick files in android.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, permission_handler, provider

More

Packages that depend on filesaverz