flutter_file_saver

melos Pub Version

Interface to provide a way to save files on the device in Flutter.

Platform Support

Android iOS Web Windows Linux MacOS
writeFileAsBytes ❌️ ❌️
writeFileAsString ❌️ ❌️

Getting Started

Import the package

dependencies:
    flutter_file_saver: any

Platform Setup

Android Setup
android {
    defaultConfig {
        minSdkVersion 19
    }
}

Check example

iOS Setup

Add the following permissions to your ios/Runner/Info.plist:

<key>UISupportsDocumentBrowser</key>
<true/>
<key>UIFileSharingEnabled</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>

Check example

MacOS Setup

Add the following permissions to your macos/Runner/DebugProfile.entitlements:

<key>com.apple.security.files.user-selected.read-write</key>
<true/>

Check example

Methods

writeFileAsBytes

Write a file on the device from a Uint8List.

FlutterFileSaver().writeFileAsBytes(
    fileName: 'file.txt',
    bytes: fileBytes,
);

writeFileAsString

Write a file on the device from a String. This will most of the time convert your data and perform a call to writeFileAsBytes.

FlutterFileSaver().writeFileAsString(
    fileName: 'file.txt',
    string: 'Hello World!',
);

Todo

  • Support for Windows & Linux
  • Support custom local paths

Libraries

flutter_file_saver