file_picker_android 1.0.1 copy "file_picker_android: ^1.0.1" to clipboard
file_picker_android: ^1.0.1 copied to clipboard

PlatformAndroid

A package that allows you to use the native file explorer to pick single or multiple files, with extensions filtering support.

file_picker_android #

Flutter plugin for pick file/files on Android without any permission.

With this plugin a Flutter app allows you to use the native file explorer to pick single or multiple files, with extensions filtering support.

Example #

import 'package:file_picker_android/file_picker_android.dart';

  final _filePickerAndroidPlugin = FilePickerAndroid();

  void pickFiles({bool? openMultiple, List<String>? acceptTypes}) async {
    final result = await _filePickerAndroidPlugin.pickFile(openMultiple: openMultiple, acceptTypes: acceptTypes);
    setState(() {
      _filePaths = result.join('\n');
    });
  }
  
  Text('FilePaths:\n* $_filePaths'),

  FilledButton(onPressed: () => pickFiles(), child: Text('Pick Single File')),
  FilledButton(onPressed: () => pickFiles(openMultiple: true), child: Text('Pick Multiple Files')),
  FilledButton(onPressed: () => pickFiles(openMultiple: true, acceptTypes: ['image/*']), child: Text('Pick Multiple Image')),
  FilledButton(onPressed: () => pickFiles(acceptTypes: ['image/*']), child: Text('Pick Single Image')),
  FilledButton(onPressed: () => pickFiles(acceptTypes: ['video/*']), child: Text('Pick Single Video')),
  FilledButton(onPressed: () => pickFiles(acceptTypes: ['video/*', 'image/*']), child: Text('Pick Multiple Image or Video')),
  FilledButton(onPressed: () => pickFiles(acceptTypes: ['image/jpeg']), child: Text('Pick Single jpeg')),

Example for webview file chooser #

import 'package:file_picker_android/file_picker_android.dart';

// ...
// webviewController init
// ...
if (_webviewController.platform is AndroidWebViewController) {
  _setupAndroidWebView();
}

void _setupAndroidWebView() {
    final androidController = _webviewController.platform as AndroidWebViewController;
    androidController.setAllowFileAccess(true);
    androidController.setAllowContentAccess(true);
    androidController.setOnShowFileSelector(_handleAndroidFileSelection);
}

Future<List<String>> _handleAndroidFileSelection(FileSelectorParams params) async {
  final filePickerAndroidPlugin = FilePickerAndroid();
  final result = await filePickerAndroidPlugin.pickFile(
    openMultiple: params.mode == FileSelectorMode.openMultiple,
    acceptTypes: params.acceptTypes,
  );
  return result;
}
0
likes
150
points
102
downloads

Publisher

unverified uploader

Weekly Downloads

A package that allows you to use the native file explorer to pick single or multiple files, with extensions filtering support.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on file_picker_android

Packages that implement file_picker_android