filesaverz 1.1.0 filesaverz: ^1.1.0 copied to clipboard
A package that makes it easy for user to browse folder and save file in android.
File Saver Z #
A package that makes it easy for user to browse folder and save file.
Preview #
Usage #
First, add permission in you 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';
And set fileSaver widget like this.
FileSaver fileSaver = FileSaver(
initialFileName: 'New File',
fileTypes: const ['.txt','.pdf'],
);
Now in async function, call this to getPath.
String? path = await fileSaver.getPath(context);
Use this to call File(path).writeAsBytes(bytes)
function.
fileSaver.writeAsBytes(bytes, context: context);
Use this to call File(path).writeAsBytesSync(bytes)
function.
fileSaver.writeAsBytesSync(bytes, context: context);
Use this to call File(path).writeAsString(contents)
function.
fileSaver.writeAsString(contents, context: context);
Use this to call File(path).writeAsStringSync(contents)
function.
fileSaver.writeAsStringSync(contents, context: context);
Documentation #
-
Widget?
headerBuilder
:
Is an optional header widget. Default widget only shows title and close button.headerBuilder: (context, state) => Widget(),
-
Widget?
bodyBuilder
:
Is an optional widget as well. By Default displaying list ofFileSystemEntity
.bodyBuilder: (context, state) => Widget(),
-
Widget?
footerBuilder
:
Is also an optional widget. It's displaying option to input new file name and select file types.footerBuilder: (context, state) => Widget(),
-
FileSaverStyle?
style
:
A custom style inFileSaver
. It contains colors and textstyles.style: FileSaverStyle(primaryColor: Colors.orange);
-
String
initialFileName
:
Is a file name. If user enters new name, this will be replaced.initialFileName: 'New File';
-
Director?
initialDirectory
:
Is an optional directory. If initialDirectory is null, in android it will call a method channel ofEnvironment.getExternalStorageDirectory()
. -
List<String>
fileTypes
:
Displaying list of file extensions.fileTypes: const ['.txt','.pdf','.rtf'];