Flutter_file_picker: Single plugin for Android/IOS/Web

Created on 2 Aug 2020  路  5Comments  路  Source: miguelpruivo/flutter_file_picker

After many hours of investigation I now know how to make a plug-in for the three platforms. You only need to make very small changes in 5 files. I have tested it. Let me know if you want me to send details.

wip

Most helpful comment

I made a local copy and used relative references (ie path in .yaml), so you will have to adapt.

in file_picker.dart, change line 10 to:
final FilePickerPlatform _filePickerPlatform = FilePickerPlatform.instance;

in file_picker/pubspec.yaml
dependencies:
flutter:
sdk: flutter
flutter_plugin_android_lifecycle: ^1.0.6
file_picker_platform_interface:
path: ../file_picker_platform_interface
file_picker_web:
path: ../file_picker_web

in file_picker_platform_interface.dart, line 56, add to method getFiles parameter: bool allowCompression = true,

in file_picker_web class name cannot be same as in file_picker, so I changed to:
class FilePickerWeb

in file_picker_web/pubspec.yaml
flutter:
plugin:
platforms:
web:
pluginClass: FilePickerWeb <--- new class name
fileName: file_picker_web.dart

And that's it. Let me know if it helps.

All 5 comments

@edandaria if you are speaking of stubbing it won鈥檛 properly because File instance must be different on both html and io. But I鈥檇 be glad to know!

I made a local copy and used relative references (ie path in .yaml), so you will have to adapt.

in file_picker.dart, change line 10 to:
final FilePickerPlatform _filePickerPlatform = FilePickerPlatform.instance;

in file_picker/pubspec.yaml
dependencies:
flutter:
sdk: flutter
flutter_plugin_android_lifecycle: ^1.0.6
file_picker_platform_interface:
path: ../file_picker_platform_interface
file_picker_web:
path: ../file_picker_web

in file_picker_platform_interface.dart, line 56, add to method getFiles parameter: bool allowCompression = true,

in file_picker_web class name cannot be same as in file_picker, so I changed to:
class FilePickerWeb

in file_picker_web/pubspec.yaml
flutter:
plugin:
platforms:
web:
pluginClass: FilePickerWeb <--- new class name
fileName: file_picker_web.dart

And that's it. Let me know if it helps.

Hey @edandaria , why don't you open a pull request

FYI: I'm already working on this along with #234, expect a release this week. 馃帀

Update is now live with 2.0.0 please, see the changelog for details of what have changed.

Let me know if you experience any issue! 馃帀

Thank you!

Was this page helpful?
0 / 5 - 0 ratings