Last updated:
0 purchases
filesaverz
File Saver Z #
A customable file saver and file picker package that makes it easy for user to browse folder and save file or pick files in android.
Preview #
Install #
Add this to your pubspec.yaml.
dependencies:
filesaverz: ^3.2.1
copied to clipboard
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"/>
copied to clipboard
Just in case if you got MissingPluginException(No implementation found for method checkPermissionStatus on channel flutter.baseflow.com/permissions/methods) error, try fix it by adding this to your app/build.gradle.
buildTypes {
release {
shrinkResources false
minifyEnabled false
signingConfig signingConfigs.release
}
}
copied to clipboard
And then import the filesaver (with z) package.
import 'package:filesaverz/filesaverz.dart';
copied to clipboard
Usage #
First, setting up the FileSaver widget like this.
FileSaver fileSaver = FileSaver(
fileTypes: const ['txt','pdf'],
initialFileName: 'Untitled File',
);
copied to clipboard
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 */,
);
copied to clipboard
And then in async function call these:
Purpose
Code
Getting selected path from saving file.
String? path = await fileSaver.getPath(context);copied to clipboard
Calling writeAsBytes method.
fileSaver.writeAsBytes(bytes, context: context);copied to clipboard
Calling writeAsBytesSync method.
fileSaver.writeAsBytesSync(bytes, context: context);copied to clipboard
Calling writeAsString method.
fileSaver.writeAsString(contents, context: context);copied to clipboard
Calling writeAsStringSync method.
fileSaver.writeAsStringSync(contents, context: context);copied to clipboard
Picking single file.
File? file = await fileSaver.pickFile(context);copied to clipboard
Picking multiple files.
List<File>? files = await fileSaver.pickFiles(context);copied to clipboard
Documentation #
Property
Code
headerBuilder, an optional builder.
(context, state) {
return Text('My Custom Header Widget');
},
copied to clipboard
bodyBuilder, an optional builder.
(context, state) {
return Text('My Custom Body Widget');
},
copied to clipboard
footerBuilder, an optional builder
(context, state) {
return Text('My Custom Footer Widget');
},
copied to clipboard
style, set custom Color, TextStyle, Icon and displayed Text.
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)),
],
text: FileSaverText(
popupNo: 'Nay',
popupYes: 'Sí',
),
),
copied to clipboard
initialFileName, this property is used when you call saving method.
'Untitled File',
copied to clipboard
initialDirectory, in Android by default it's calling Environment.getExternalStorageDirectory.
Directory('Storage Path'),
copied to clipboard
fileTypes, this property is used to limit what kind of fileTypes that we want to display, and in saving method this fileTypes also used as an option for user to set the desired fileTypes to write.
const ['jpg','gif','png'],
copied to clipboard
Full Documentation here.
Example #
filesaverz/example/lib/main.dart
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.