Site icon Flutter Packages | Pub dev Packages – Flutter Mobile App World

Flutter Document Picker Plugin

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

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:

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);

Getting Started

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.

Download Flutter Document Picker Source Code on GitHub

https://github.com/sidlatau/flutter_document_picker

Exit mobile version