Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/Nialixus/filesaverz

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.
https://github.com/Nialixus/filesaverz

dart flutter flutter-package pub-dev

Last synced: 7 days ago
JSON representation

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.

Awesome Lists containing this project

README

        




# 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

![screen-capture (1)](https://user-images.githubusercontent.com/45191605/167116228-6cbddb50-d98a-44d3-af1f-ce2b61ae8464.gif)

## Install

Add this to your `pubspec.yaml`.

```yaml
dependencies:
filesaverz: ^3.2.1
```

Continue by adding permission in your `AndroidManifest.xml`.

```xml



```

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`.

```gradle
buildTypes {
release {
shrinkResources false
minifyEnabled false
signingConfig signingConfigs.release
}
}
```

And then import the filesaver (with z) package.

```dart
import 'package:filesaverz/filesaverz.dart';
```

## Usage

First, setting up the FileSaver widget like this.

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

or this customable FileSaver.

```dart
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&ltFile&gt? 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, 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í',
),
),




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, 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'],


Full Documentation [here](https://pub.dev/documentation/filesaverz/latest/filesaverz/filesaverz-library.html).

## Example

- [filesaverz/example/lib/main.dart](https://github.com/Nialixus/filesaverz/blob/master/example/lib/main.dart)