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

插件详情v5.2.3

flutter_document_picker

允许用户选择文档。所选文档将复制到应用临时目录中。可选择仅允许选择特定扩展名的文档。

AndroidiOS
近 30 天下载
1.9万
喜欢数
52
Pub 分数
150

安装插件

flutter pub add flutter_document_picker

插件介绍

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

一个 Flutter 包,允许用户从设备的文件系统中选择文档。所选文档会自动复制到应用的临时目录中,以确保安全访问。它支持按特定扩展名过滤文件,从而提升针对特定文件选择的可用性。可在 Android 和 iOS 上使用,并与原生文件选择器无缝集成。适用于需要上传或导入文档但无需直接访问文件系统的应用程序。

适合场景

  • 表单中的文档上传
  • 导入用户生成的文件
  • 应用间文件共享
  • 读取外部配置文件
  • 支持基于文档的工作流程

主要特点

  • 选择带有扩展名过滤的文档
  • 自动将文件复制到临时目录
  • 跨平台(Android & iOS)
  • 简单的 API 集成
  • 安全的临时文件处理

适合对象

  • 需要文件输入的应用程序
  • 文档管理功能
  • 用户驱动的文件导入
  • 移动数据采集工具
  • 注重隐私的文件访问

使用建议

  • 文件被复制到临时存储
  • 仅限支持的文件类型
  • 需要平台特定权限
  • 临时文件可能在应用重启时被删除
  • 无法直接访问原始文件路径

原始 README

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

flutter_document_picker

Allows user pick a document. Picked document is copied to app temporary directory. Optionally allows pick document with specific extension only.

When file is picked its extension is checked using allowedFileExtensions parameter. Then file is copied to app temp directory. Copied file path is returned as result. If picked file extension is not in allowedFileExtensions list then extension_mismatch error is returned.

In Android Intent.ACTION_OPEN_DOCUMENT is used. This intent is supported only from Android 19 (KitKat) SDK version. So this plugin can be used only if app minSdkVersion is 19 or more.

In iOS UIDocumentPickerViewController is used. Files can be filtered by list of UTI types using allowedUtiTypes parameter. Picked file path is returned as result.

Params

Plugin has 3 optional parameters to help pick only specific document type:

  • List<String> allowedUtiTypes (used only in iOS)

    In iOS Uniform Type Identifiers is used to check document types. If list is null or empty "public.data" document type will be provided. Only documents with provided UTI types will be enabled in iOS document picker.

    More info: https://developer.apple.com/library/archive/qa/qa1587/_index.html

  • List<String> allowedFileExtensions (used both in iOS and in Android)

    List of file extensions that picked file should have. If list is null or empty - picked document extension will not be checked.

  • List<String> allowedMimeTypes (used only in Android)

    Only files with provided MIME types will be shown in document picker. If list is null or empty - */* MIME type will be used.

  • List<String> invalidFileNameSymbols (used both in iOS and in Android)

    List symbols that will be sanitized to "_" in the selected document name. I.e. Google Drive allows symbol '/' in the document name, but this symbol is not allowed in file name that will be saved locally.

    Default list: ['/'].

    Example: file name 'Report_2018/12/08.txt' will be replaced to 'Report_2018_12_08.txt'

Example

//Without parameters:
final path = await FlutterDocumentPicker.openDocument();
  
  ...

    
//With parameters:
FlutterDocumentPickerParams params = FlutterDocumentPickerParams(      
  allowedFileExtensions: ['mwfbak'],
  allowedUtiTypes: ['com.sidlatau.example.mwfbak'],
  allowedMimeTypes: ['application/*'],
  invalidFileNameSymbols: ['/'],
);

final path = await FlutterDocumentPicker.openDocument(params: params);

//Pick multiple files:
final paths = await FlutterDocumentPicker.openDocuments(params: params);

所属分类

源码仓库

使用此插件的项目

暂无相关数据。