file_picker_writable 1.0.0 copy "file_picker_writable: ^1.0.0" to clipboard
file_picker_writable: ^1.0.0 copied to clipboard

outdated

Flutter plugin to allow users to open files/documents which can be read, and written back at a later time as well as creating new files on external media.

file_picker_writable #

Flutter plugin to choose files which can be read, referenced and written back at a later time (persistent permissions on android, secure bookmarks on iOS).

Requirements #

iOS #

  • iOS 8 + Swift 5
  • Only tested on iOS 13+, so let me know ;-)

Support for file handlers #

  1. Configure an OTI Type: https://developer.apple.com/library/archive/qa/qa1587/_index.html
  2. Add to plist file:
    <key>UISupportsDocumentBrowser</key>
    <false/>
    <key>LSSupportsOpeningDocumentsInPlace</key>
    <true/>
    

Android #

  • Android 4.4 (API Level 4.4)
  • Only supports plugin api v2.
    • (v1 is implemented but untested)

Support for file handlers #

AndroidManifest.xlm

            <intent-filter>
                <action android:name="android.intent.action.VIEW"  />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="file" />
                <data android:scheme="content" />
                <data android:host="*"  />
                <data android:mimeType="*/*" />
                <!-- https://stackoverflow.com/a/52384331/109219 ?? -->
                <data android:pathPattern=".*\\.codeux" />
                <data android:pathPattern=".*\\..*\\.codeux" />
                <data android:pathPattern=".*\\..*\\..*\\.codeux" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.codeux" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.codeux" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.*\\..*\\.codeux" />
            </intent-filter>

Getting Started #

See the example on how to implement it in a simple application.

Future<void> readFile() async {
  final fileInfo = await FilePickerWritable().openFilePicker();
  _logger.fine('Got picker result: $fileInfo');
  if (fileInfo == null) {
    _logger.info('User canceled.');
    return;
  }
  // now do something useful with the selected file...
  _logger.info('Got file contents in temporary file: ${fileInfo.file}');
  _logger.info('fileName: ${fileInfo.fileName}');
  _logger.info('Identifier which can be persisted for later retrieval:'
      '${fileInfo.identifier}');
}

The returned fileInfo.identifier can be used later to write or read from the data, even after an app restart.

Future<void> persistChanges(FileInfo fileInfo, Uint8List newContent) async {
  // create a new temporary file inside your apps sandbox.
  final File newFile = _createNewTempFile();
  await newFile.writeBytes(newContent);

  // tell FilePickerWritable plugin to write the new contents over the user selected file
  await FilePickerWritable()
     .writeFileWithIdentifier(fileInfo.identifier, newFile);
}
14
likes
0
pub points
81%
popularity

Publisher

verified publishercodeux.design

Flutter plugin to allow users to open files/documents which can be read, and written back at a later time as well as creating new files on external media.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

convert, flutter, logging

More

Packages that depend on file_picker_writable