diff --git a/CHANGELOG.md b/CHANGELOG.md index 25145a7..20f3dfd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,8 +14,7 @@ ## 1.2.0 -**Breaking change** - Migrate from the deprecated original Android Support Library to AndroidX. This shouldn't result in any functional changes, but it requires any Android apps using this plugin to [also migrate](https://developer.android.com/jetpack/androidx/migrate) if they're using the original support library. +**Breaking change**: Migrate from the deprecated original Android Support Library to AndroidX. This shouldn't result in any functional changes, but it requires any Android apps using this plugin to [also migrate](https://developer.android.com/jetpack/androidx/migrate) if they're using the original support library. ## 1.1.1 diff --git a/README.md b/README.md index 2415b7b..418bbb6 100644 --- a/README.md +++ b/README.md @@ -44,15 +44,21 @@ Picking multiple paths from iOS gallery (image and video) aren't currently suppo #### Usages -So, a few basically usages can be as follow: +So, a few example usages can be as follow: ``` +// Single file path String filePath; filePath = await FilePicker.getFilePath(type: FileType.ANY); // will let you pick one file, from all extensions filePath = await FilePicker.getFilePath(type: FileType.CUSTOM, fileExtension: 'svg'); // will filter and only let you pick files with svg extension. +// Multi file path Map filesPaths; filePaths = await FilePicker.getMultiFilePath(); // will let you pick multiple files of any format at once filePaths = await FilePicker.getMultiFilePath(fileExtension: 'pdf'); // will let you pick multiple pdf files at once + +List allNames = filePaths.keys; // List of all file names +List allPaths = filePaths.values; // List of all paths +String someFilePath = filePaths['fileName']; // Access a file path directly by its name (matching a key) ``` ##### A few notes @@ -73,51 +79,7 @@ filePaths = await FilePicker.getMultiFilePath(fileExtension: 'pdf'); // will let ![Demo](https://github.com/miguelpruivo/plugins_flutter_file_picker/blob/master/example/example.gif) ## Example -``` -import 'package:file_picker/file_picker.dart'; - -class MyHomePage extends StatefulWidget { - @override - _MyHomePageState createState() => new _MyHomePageState(); -} - -class _MyHomePageState extends State { - String _filePath; - - void getFilePath() async { - try { - String filePath = await FilePicker.getFilePath(type: FileType.ANY); - if (filePath == '') { - return; - } - print("File path: " + filePath); - setState((){this._filePath = filePath;}); - } on PlatformException catch (e) { - print("Error while picking the file: " + e.toString()); - } - } - - @override - Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar( - title: new Text('File Picker Example'), - ), - body: new Center( - child: _filePath == null - ? new Text('No file selected.') - : new Text('Path' + _filePath), - ), - floatingActionButton: new FloatingActionButton( - onPressed: getFilePath, - tooltip: 'Select file', - child: new Icon(Icons.sd_storage), - ), - ); - } -} - -``` +See example app. ## Getting Started diff --git a/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java b/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java index 096a15e..d8ebdc2 100644 --- a/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java +++ b/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java @@ -12,11 +12,8 @@ import androidx.core.content.ContextCompat; import android.util.Log; import android.webkit.MimeTypeMap; -import java.io.BufferedOutputStream; + import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; import java.util.ArrayList; @@ -176,8 +173,6 @@ public class FilePickerPlugin implements MethodCallHandler { intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, isMultipleSelection); intent.addCategory(Intent.CATEGORY_OPENABLE); - Log.d(TAG, "Intent: " + intent.toString()); - instance.activity().startActivityForResult(intent, REQUEST_CODE); } else { requestPermission(); diff --git a/example/example.gif b/example/example.gif index 328cc1c..c450cf8 100644 Binary files a/example/example.gif and b/example/example.gif differ