flutter_file_dialog

v3.0.3

Dialogs for picking and saving files in Android and in iOS.

Package archive: https://pubdev.letsnova.ru/api/archives/flutter_file_dialog/3.0.3.tar.gz

Installdart pub add flutter_file_dialog

Readme

flutter_file_dialog

Dialogs for picking and saving files and for picking directories in Android and in iOS.

Features

  • Supports Android (API level 19 or later) and iOS (11.0 or later).
  • Modern plugin implementation based on Kotlin (Android) and Swift (iOS).
  • Pick image files and other documents.
  • Save a file to a selected location.
  • Pick a directory and save files to the picked directory without further dialogs (Android 21 or later, iOS 13 or later).
  • iOS dialog types: document and image.
  • iOS source types: camera, photo library, saved photos album.
  • Allow user to edit the picked image in iOS.
  • Set file extension filter and mime types filter when picking a document.
  • Possibility to limit picking a file from the local device only (Android).

Examples

Pick an image file

  final params = OpenFileDialogParams(
                    dialogType: OpenFileDialogType.image,
                    sourceType: SourceType.photoLibrary,
                  );
                  final filePath = await FlutterFileDialog.pickFile(params: params);
                  print(filePath);
                

Pick a document

  final params = OpenFileDialogParams(
                    dialogType: OpenFileDialogType,
                    sourceType: SourceType.photoLibrary,
                  );
                  final filePath = await FlutterFileDialog.pickFile(params: params);
                  print(filePath);
                

Save a file

final params = SaveFileDialogParams(sourceFilePath: "path_of_file_to_save");
                final filePath = await FlutterFileDialog.saveFile(params: params);
                print(filePath);
                

Pick a directory and save a file to the picked directory

if (!await FlutterFileDialog.isPickDirectorySupported()) {
                  print("Picking directory not supported");
                  return;
                }
                
                final pickedDirectory = await FlutterFileDialog.pickDirectory();
                
                if (pickedDirectory != null) {
                  final filePath = await FlutterFileDialog.saveFileToDirectory(
                    directory: pickedDirectory!,
                    data: file.readAsBytesSync(),
                    mimeType: "image/jpeg",
                    fileName: "fileName.jpeg",
                    replace: true,
                  );
                }
                

Optimize picked image file using flutter_image_utilities

Use the plugin flutter_image_utilities to optimize a picked image file.

  final params = OpenFileDialogParams(
                    dialogType: OpenFileDialogType.image,
                    sourceType: SourceType.photoLibrary,
                  );
                  final filePath = await FlutterFileDialog.pickFile(params: params);
                  print(filePath);
                
                  if (filePath != null) {
                    final pickedFile = File(filePath)
                
                    // optimize the image file
                    final optimizedFile = await FlutterImageUtilities.saveAsJpeg(
                      sourceFile: pickedFile,
                      quality: 60,
                      maxWidth: 1920,
                      maxHeight: 1024,
                    );
                  }
                

Changelog

3.0.3

  • [Android] Updated compileSdkVersion to 36, Gradle to 8.14 and Java/Kotlin compatibility to version 17
  • [Android] Additional fix for #31: java.lang.IllegalStateException Reply already submitted

3.0.2

3.0.1

  • Adds a namespace for compatibility with AGP 8.0. Thanks to @asaarnak!

3.0.0

  • Allow picking a directory and saving files to the picked directory without further dialogs. Thanks to @Doflatango!
  • minimum iOS version is now 11

2.3.2

  • [Android] Fixed #28: Extra content being saved to end of file sometimes. Thanks to @hygehyge!

2.3.1

  • [Android] Fixed #31: java.lang.IllegalStateException Reply already submitted

2.3.0

  • [iOS] Added support for iOS 10

2.2.0

  • [Android] upgraded gradle
  • [Android] jcenter => mavenCentral
  • [Android] removed obsolete android.enableR8
  • [Android] updated to Kotlin 1.5.30
  • [Android] set compileSdkVersion to 31
  • [Android] Removed V1 embedding

2.1.1

[iOS] Fixed #14 Document picker dialog could not be closed by dragging it down

2.1.0

[iOS] Fixed #14 FlutterFileDialog.pickFile doesn't return value if picker is slid down [iOS] Fixed issue with relative paths in saveFile [Android] #12 Added a new parameter OpenFileDialogParams.copyFileToCacheDir (Android only) [Android] Updated compileSdkVersion and targetSdkVersion to 30

2.0.0

  • null safety

1.0.0

  • added SaveFileDialogParams.fileName for specifying a suggested file name
  • added SaveFileDialogParams.data for prodiving file data instead of source file path

0.0.5

[Android] Fixed: any thrown exception caused crash. Now exception is delivered correctly to caller.

0.0.4

  • [Android] Improved error handling.

0.0.3

  • [iOS] Use background threads where needed to keep UI more responsive.

0.0.2

  • Fixed a possible crash in apps using mixed Android V1/V2 embedding (issue #1)

0.0.1+1

  • Minor cleanup.

0.0.1

  • Initial release.