flutter_file_saver 0.7.0+1 flutter_file_saver: ^0.7.0+1 copied to clipboard
Interface to provide a way to save files on the device in Flutter.
flutter_file_saver #
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 #
iOS Setup
Add the following permissions to your ios/Runner/Info.plist
:
<key>UISupportsDocumentBrowser</key>
<true/>
<key>UIFileSharingEnabled</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
MacOS Setup
Add the following permissions to your macos/Runner/DebugProfile.entitlements
:
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
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