Suggestion Box
miguelpruivo opened this issue · 74 comments
Suggestions Box
Please, if you have any suggestion add it here and I'll try to keep track of those, as well we can try to discuss which will make sense to implement or not in the package.
The list order is from the most likely to be added to the less.
To-do list
- Support Flutter desktop (#85) - Currently implemented with go-flutter as an alternative 🎉
- Allow multiple extensions at once (#68)
- Get an URL from remote files (eg. GDrive) (#63)
- Picking directory (although this is not an easy task in iOS) (#23)
- Support Flutter Web (#84) (WIP)
- Support picking videos and photos at once on iOS (#181)
+1 For Flutter desktop support
Please add directory selection, so go-flutter-desktop file_picker plug-in can add this new feature.
Please see the follwing comments.
go-flutter-desktop/plugins#3 (comment)
Thanks
Flutter Desktop support would be amazing! :-)
Please add support for multiple fileType in singleFilePath.
e.g.
I want to select a single file which can be either IMAGE or PDF. I know I can use CUSTOM fileType but I don't user to select any other fileType then IMAGE and PDF.
+1 for #68
@tolstenko desktop is already in progress, see discussion here.
desktop is already in progress, see discussion here.
The discussion you linked to is about the go-flutter-desktop project. The Flutter desktop support that was requested in #85 specifically referred to the Flutter project's in-development support for desktop (which is probably what people referring to Flutter desktop are likely to mean unless they specifically mention a community project like go-flutter-desktop or flutter-rs).
Those two things have completely separate plugin APIs, tooling, and even languages, and thus require completely different implementations.
@stuartmorgan oh, right! Now I get why you were referring to desktop-go instead of just desktop.
That’s great anyway, somehow I thought you were already developing a file picker for a desktop flutter shell and you’d want to merge it with this package.
There is actually already a file picker plugin for desktop Flutter (macOS and Linux so far, Windows to be implemented). It may actually become part of Flutter for desktop itself in the future, but in the meantime if someone wants to make (non-Go) desktop implementations of this plugin for API compatibility reasons it could be used as a starting point.
+1 for Picking directory please
Yes I’m aware of that @stuartmorgan. It’s not the flutter desktop but it’s a desktop implementation anyway, that’s why in the details it is mentioned that is done through go-flutter.
It’s not the flutter desktop but it’s a desktop implementation anyway
So does that mean #85 is a wont-fix?
@stuartmorgan I got you. No, it isn’t. It might be implemented anyway, but fortunately now we’ve a good desktop solution.
Would it be too much work to obtain mime/contentType for image files? I need it for file uploads and I was told <input type="file">
in web browsers does it out of the box.
could type not be just one type or any ?
for example if i want the user will pick only from png & jpeg files...
@davidSafeGuard yes, that’s already listed in the suggestions as custom rules (#77). Thank you!
I want to help implement web support. Where do I start?
@Robert3141 I'm afraid you can't at the moment because there is no support for calling underlying platform plugins for the Flutter Web at the moment and you actually need it. Unless something changed that I could have missed.
I need support for network drives (local network) and ftp/http locations for files.
Especially network drives.
It will be great
+1 for #68
@miguelpruivo @Robert3141 for web support, can't we use FileUploadInputElement
from dart:html
? just like the example in https://stackoverflow.com/a/56648742/388322
In order to import dart:html
in web, here are some references:
@guiguan definitely got to give it a try. It would get rid of calling underlying platforms directly and should work with all browsers.
Good catch. Thank you.
@miguelpruivo I tested the idea and came out with the following code. Due to the lack of accurately capturing the cancel
event on HTML element side, I used a timer to make sure everything (e.g. subscribed stream) is correctly cleaned up after each invocation. You may have a better idea :P
import 'package:universal_html/prefer_universal/html.dart' as html;
import 'dart:async';
/// Browse a file using the file picker of user's browser. The user has 60 seconds to finish the
/// task until the operation is treated as canceled
Future<html.File> browseFile() async {
html.InputElement uploadInput = html.FileUploadInputElement();
uploadInput.click();
final c = Completer();
final fn = ([_]) => c.complete();
final sub = uploadInput.onChange.listen(fn, onError: fn, onDone: fn);
await Future.any([c.future, Future.delayed(const Duration(seconds: 60))]);
sub.cancel();
final files = uploadInput.files;
if (files.length == 1) {
return files[0];
}
return null;
}
can you please add multiple file type support when selecting a single file. I want the user to pick only one image or video.
@Bhaluu thank you for the input, that's one of the requested features that may come in an upcoming update.
Can we have an option to capture image from camera as well?
@guptahitesh121 this was already available in previous versions of file_picker
and was removed on 1.3.0 because it was forcing some users to provide camera permissions when publishing the app, even if they weren't using the camera at all. Also, this way, the plugin is lighter and more modular and you can always use it along with ìmage_picker
wich is from the FlutterDev team and allows you to pick paths from camera/gallery.
I'm not sure if it can pick up a folder or not. If it can, can you please add a small example on how to use this for picking up the folder. I had a specific requirement to make the user select a path and not a file.
@Murtuzakabul you can see on this exactly issue that that is one of the requested features but is still not implemented (and I believe that's not possible in iOS though). However, as workaround, you can pick folders by just letting the user pick some file and removing the file name. It's not the best solution, but works for now.
@miguelpruivo This is what I am doing exactly as a workaround. However, the app I'm working on is purely desktop and I have no intentions to deploy it on mobile. I'm also using the file picker function and it is working great. I would like to extend the functionality of this plugin to include folder picker function. As I am not very good at golang, request you to give me some pointers to start with. Thanks.
As a user of flutter's master channel I must say that desktop support has been improved rapidly the last couple of months. Please consider support for the official flutter desktop strategy. It's really quite easy to write Windows & macOS plugins: https://github.com/flutter/flutter/wiki/Desktop-shells#plugins
Would it be too much work to obtain mime/contentType for image files? I need it for file uploads and I was told
<input type="file">
in web browsers does it out of the box.
For all file types please
@miguelpruivo This is what I am doing exactly as a workaround. However, the app I'm working on is purely desktop and I have no intentions to deploy it on mobile. I'm also using the file picker function and it is working great. I would like to extend the functionality of this plugin to include folder picker function. As I am not very good at golang, request you to give me some pointers to start with. Thanks.
Is there any chance of this feature in near future. I can understand that that it is lot of work as the implementation is quite complicated for different platforms. Further, it is probably impossible in iOS. As a head start, is it possible to get it done just for desktop platforms for now. I am doing a desktop app and I really miss this feature.
Is it possible to limit the number of files that can be picked?
On native pickers I’m afraid not @guit4eva, but you can do that on the apps side after picking.
@miguelpruivo any chance that a web version might be coming soon?
@rlee1990 I would like to, but I can’t promise you a date. There are a few things on the pipeline that I’d like to implement first.
@miguelpruivo I understand. Web is still in beta anyway for the time being what @guiguan suggested works so I will use that for now.
@rlee1990 I might add web support in the next release anyhow, since it should be quite easy to include it anyway.
I’ll keep you updated.
@miguelpruivo thanks once I have some free time I'd love to help if possible.
@rlee1990 @guiguan and some others that wanted web support, I've drafted the implementation and I believe that can be handled right away (even though is inserted on the same plugin to make it easier as of now).
Would you mind to please give it a try on one of your web projects that required it by using a reference to the web-support
branch instead:
file_picker:
git:
url: https://github.com/miguelpruivo/plugins_flutter_file_picker.git
ref: web-support
and then use the method:
final List<html.File> files = await FilePicker.getFilesForWeb();
Which will give you a list of html.File
objects. Currently I haven't add any filter support at all, just wanted to make it available for those requiring the plugin to work at all.
I have also updated the example app, so you should be fine testing out the plugin's example by running flutter run -d chrome
.
Thank you!
@miguelpruivo sorry for the late reply but I get this error:
A value of type 'List<File> (where File is defined in D:\nexttech\flutter_windows_v1.5.4-hotfix.2-stable\flutter\bin\cache\pkg\sky_engine\lib\html\html_dart2js.dart)' can't be assigned to a variable of type 'List<File> (where File is defined in D:\nexttech\flutter_windows_v1.5.4-hotfix.2-stable\flutter\.pub-cache\hosted\pub.dartlang.org\universal_html-1.1.12\lib\src\html\api\file.dart)'. Try changing the type of the variable, or casting the right-hand type to 'List<File> (where File is defined in D:\nexttech\flutter_windows_v1.5.4-hotfix.2-stable\flutter\.pub-cache\hosted\pub.dartlang.org\universal_html-1.1.12\lib\src\html\api\file.dart)'.
If I just set it as: final List<html.File> files = await FilePicker.getFilesForWeb();
But if I set it as: final List<html.File> files = (await FilePicker.getFilesForWeb()).cast<html.File>();
No error
Sorry @miguelpruivo it works just gives you those errors.
@rlee1990 you shouldn’t have to cast because I’m already returning a List<html.File>
. Anyhow, is it working?
@miguelpruivo it does work and it only makes me cast if I make my list a list of html.File
@rlee1990 weird. It should be the same object instance. How are you importing your html.File
?
@miguelpruivo I import it the way @guiguan suggested
@miguelpruivo you do not if you type it like this:
final List files = await FilePicker.getFilesForWeb();
it will work with no issue
@rlee1990 what's the exception thrown if you do:
List<html.File> files = await FilePicker.getFilesForWeb();
I get this:
`A value of type 'List (where File is defined in D:\nexttech\flutter_windows_v1.5.4-hotfix.2-stable\flutter\bin\cache\pkg\sky_engine\lib\html\html_dart2js.dart)' can't be assigned to a variable of type 'List (where File is defined in D:\nexttech\flutter_windows_v1.5.4-hotfix.2-stable\flutter.pub-cache\hosted\pub.dartlang.org\universal_html-1.1.12\lib\src\html\api\file.dart)'. Try changing the type of the variable, or casting the right-hand type to 'List (where File is defined in D:\nexttech\flutter_windows_v1.5.4-hotfix.2-stable\flutter.pub-cache\hosted\pub.dartlang.org\universal_html-1.1.12\lib\src\html\api\file.dart)'.
Hum, I get it @rlee1990. We are using different File
imports. Just use the same and you should be fine. Are you using: import 'dart:html' as html;
?
How about add and argument for Recent Folder
? Just like
static Future<File> getFile({
FileType type = FileType.ANY,
String fileExtension,
String recentFolder, // recent folder, default null
});
static Future<String> getFilePath({
FileType type = FileType.ANY,
String fileExtension,
String recentFolder, // recent parent folder, default null
})
It's very popular feature in desktop. Maybe very useful in Android too.
I'm getting the following error:
Error: Expected a value of type 'File', but got one of type 'File$'
with:
Future<void> pickImage({Function callback, Function callbackSetTmpImgFile}) async {
try {
final List selectedImageFile = await FilePicker.getFilesForWeb();
cropImage(selectedImageFile[0], callback, callbackSetTmpImgFile);
} catch (e) {
print("Error: $e");
}
}
@miguelpruivo Make this an optional argument? There is no harm to iOS.
@pedia I'm afraid that would not result in any change on iOS and I want to make this plugin as seamless as possible platform wise.
Might make some sense on Desktop though.
@guit4eva that should only work when running on Flutter Web. Are. you using with it?
@miguelpruivo Yes, this error occurs when running the web version (Chrome).
@miguelpruivo
Could you add the file save dialog functionality ?
I am looking for a way to export a file and let the user save it wherever he wants to.
The idea is to open the native file explorer and the user save the file where he wants.
For exemple Google Drive if he wants to...
The package " https://pub.dev/packages/flutter_file_dialog" open the dialog to save a file, but it make the app crash....and the file is not saved.
Thanks
flutter_file_picker does not prevent picking files with another extension when using the filter on extension.
Is it possible to set the Image Quality, as we have in image_picker package?
@ppcapel that image quality you’re referring to is for the camera capture image quality. Since this plugin doesn’t use camera at all (only picking files) I would say that it doesn’t make much sense here.
The same goes for the image picker, I believe that image quality is only applied when taking new pictures and not from those picked from gallery.
@ppcapel that image quality you’re referring to is for the camera capture image quality. Since this plugin doesn’t use camera at all (only picking files) I would say that it doesn’t make much sense here.
The same goes for the image picker, I believe that image quality is only applied when taking new pictures and not from those picked from gallery.
@miguelpruivo in the image_picker the quality can be set to picked images too...
It works very well. It helps a lot to manage firebase storage upload sizes...
/// The imageQuality
argument modifies the quality of the image, ranging from 0-100
/// where 100 is the original/max quality. If imageQuality
is null, the image with
/// the original quality will be returned. Compression is only supportted for certain
/// image types such as JPEG. If compression is not supported for the image that is picked,
/// an warning message will be logged.
It would be nice to add FileType.CAMERA
to allow making a photo or video with the camera and return it.
image_picker has support for Camera input but does not support video.
@crtl I understand. Early versions of file picker had camera support, due to direct integration with image_picker, but then, it would force users that use file_picker to pick files, despite of using camera or not, to have the camera entitlements when publishing to the store and that could result in undesired install permissions. Also, that would require two plugins to be synced with each other, whereas now you could just use image_picker and file_picker and have a more granular control with what/when to use.
@miguelpruivo
I my flutter app is already in production. We are adding a feature that requires file uploading (csv files specifically) on the web. I tried what you suggested above
await FilePicker.getFilesForWeb();
file_picker:
git:
url: https://github.com/miguelpruivo/plugins_flutter_file_picker.git
ref: web-support
to no avail. It fails to compile with this error:
Compiler message:
../../../../.pub-cache/git/plugins_flutter_file_picker-1bf86d9fc5f3292ddbca0207bc90dc1af0598fb3/lib/file_picker.dart:26:81: Error: Getter not found: 'ANY'.
static Future<Map<String, String>> getMultiFilePath({FileType type = FileType.ANY, String fileExtension}) async =>
^^^
../../../../.pub-cache/git/plugins_flutter_file_picker-1bf86d9fc5f3292ddbca0207bc90dc1af0598fb3/lib/file_picker.dart:34:63: Error: Getter not found: 'ANY'.
static Future<String> getFilePath({FileType type = FileType.ANY, String fileExtension}) async =>
^^^
../../../../.pub-cache/git/plugins_flutter_file_picker-1bf86d9fc5f3292ddbca0207bc90dc1af0598fb3/lib/file_picker.dart:41:57: Error: Getter not found: 'ANY'.
static Future<File> getFile({FileType type = FileType.ANY, String fileExtension}) async {
^^^
../../../../.pub-cache/git/plugins_flutter_file_picker-1bf86d9fc5f3292ddbca0207bc90dc1af0598fb3/lib/file_picker.dart:62:68: Error: Getter not found: 'ANY'.
static Future<List<File>> getMultiFile({FileType type = FileType.ANY, String fileExtension}) async {
^^^
Failed to compile application.
I am happy to contribute to this package, and would like to do so right away. The best other option I have is to use another dart package that was updated sometime early last year.(called file_picker_cross
. based off your package)
The problem seem to be that the default FileType value is FileType.ANY
but the enum actual value is FileType.any
I changed all instances of FileType.ANY
to FileType.any
and it compiled and worked fine.
@AirborneEagle as pointed here in the CHANGELOG 1.5.0 introduced a breaking change that is renaming the enum for camelCase instead of upper case, thus, you must indeed refactor your code as well.
That web-support branch is unstable, but I've plans to introduce web support and already wrapped the code, although, not as complete as mobile version in the first stages.
Thanks!
Thank you. 👍
I look forward to it, and if there are ways I may be able to help, let me know.
As of now, with version 1.6.0 released just now you can start filtering multiple extensions at once. There are breaking changes, so have in mind that from now on you'll need to provide an List
of file types instead of a single one with FileType.custom
.
Example:
List<File> files = await FilePicker.getMultiFile(
type: FileType.custom,
allowedExtensions: ['jpg', 'pdf', 'doc'],
);
Web support is coming soon as well (already in progress).
I'm closing this in favor of individual issues for each requested feature (tagged with [Feature]).
Thank you.
How do I limit the number of files selection and their size? For example, I want to bound user to select 5 files only and each files cannot be more than 5Mb.
@rmsh03dhj you can’t do it as far as it concerns to native file explorer apps. They would have to support it — which they don’t.
Because of that, and IMO, it’s even a better option, you can just iterate over the picked files and check if they meet your requirements. If they don’t, show an alert/error and discard the files.
@miguelpruivo Thanks for the reply. Will try to go as per your suggestion.
It's going to be right if we only allow directory selection on the desktop tunnel.