filesaverz 1.6.0 filesaverz: ^1.6.0 copied to clipboard
A package that makes it easy for user to browse folder and save file or pick files in android.
File Saver Z #
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: ^1.6.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/filesaver.dart';
FileSaver Usage #
First, setting up the FileSaver widget like this.
/// This is default FileSaver for saving file.
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);
|
FilePicker Usage #
Setting up the FilePicker like this.
/// This is default FilePicker for picking file or files.
final filePicker = FileSaver.picker(
fileTypes: const ['jpg','gif'],
);
Purpose | Code |
Picking single file. |
File? file = await filePicker.getFile(context);
|
Picking multiple files. |
List
|
Documentation #
Full Documentation here.