搜索插件、代码仓与 APP 分类

插件详情v3.3.6

flutter_file_dialog

用于在 Android 和 iOS 上选择和保存文件的对话框。

AndroidiOS
近 30 天下载
9.7万
喜欢数
110
Pub 分数
160

安装插件

flutter pub add flutter_file_dialog

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 包,为 Android 和 iOS 提供原生文件选择器和保存对话框。它使用户能够从设备中选择文件或通过系统原生界面保存文件,确保跨平台的一致体验。该包可无缝集成到 Flutter 应用中,提供简单的 API 来触发文件操作,而无需自定义 UI。它支持常见文件类型,并尊重平台特定的文件访问权限和限制。

适合场景

  • 从设备存储中选择文件
  • 将文件保存到设备
  • 在跨平台应用中集成原生文件对话框
  • 处理媒体或文档应用中的文件输入
  • 启用用户驱动的文件管理
  • 支持文件导入/导出工作流

主要特点

  • Android 和 iOS 的原生对话框集成
  • 用于文件选择和保存的简单 API
  • 跨平台兼容性
  • 尊重平台特定的文件访问规则
  • 所需设置最少
  • 支持常见文件类型

适合对象

  • 需要文件选择或保存的应用
  • 同时针对 Android 和 iOS 的开发者
  • 需要原生文件 UI 的项目
  • 媒体或文档管理应用
  • 需要用户驱动文件处理的应用程序

使用建议

  • 需要适当的平台权限
  • 仅限文件选择/保存操作
  • 不支持网页或桌面平台
  • 依赖原生操作系统文件系统访问
  • 可能需要为特定文件类型进行额外配置

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

flutter_file_dialog

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

Features

  • Supports Android (API level 24 or later) and iOS (13.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.
  • 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,
    );
  }

所属分类

源码仓库

使用此插件的项目