Flutter_file_picker: Files number limit

Created on 14 Sep 2020  ·  12Comments  ·  Source: miguelpruivo/flutter_file_picker

Is that possible to determine the number of files the user can select?
for example, I do not want to let the user select more than 5 files.

feature-candidate

All 12 comments

Hi! This has been requested multiple times (see #314, #118, #365, #64, #353). But never implemented only because on Android it might not be honoured and would mislead some users or developers.

On iOS though this can be easily achieved.

I might add it with a disclaimer warning regarding this as it should work _most_ of the times.

Just for later reference, Android doesn't support this feature at all as referenced on the docs. This means that either the user has the ability to pick multiple files or not.

Because of this and since the feature is possible to implement on iOS, I will probably discard any N+ allowed items and display a toast with that info so the user knows it reached maximum file picks and all the N+ files were discarded because of that.

I think it will help all developers using your dependency.
Thank you for following up. 👍👍

I think it is the most important future for allow multi-select.

I want to know your input about my findings regarding this:

Android

  • It's impossible to limit or ensure the file limits other than discarding the N+ picked items (on my side) which may result in a oddly user experience, nevertheless, this would be always optional so it would be up to the devs to decide;

iOS

  • Currently, using FileType.all opens Files app (which is expected). Bottom line is that isn't impossible to limit file selection here, so it would have to act the same way as Android (discarding N+ items).
  • It's completely possible to limit the selection from gallery picking (media files). So that's a plus.

Web

  • I'm not sure if this is possible at all. If not, the same approach of Android is always possible;

With all of that said, I'm still reticent about having this feature, since it may result in significant new issues as devs may find the experience somewhat unpleasant. What's your thoughts?

Thanks!

@miguelpruivo Thank you for your reply.
In my situation, I using flutter for android and ios, that's why I'm not concerned about the web. I using React on the web.

I think the limit file is a common feature when the user selects a file. You can see many popular apps also provide that.

If you think this feature will make someone confuse, because some cases may not work. I think you can create a new method, like pickLimitFiles, and mark which case it does not work.

Thanks!

@miguelpruivo could be possible to have it for iOS? I think we can have a validation for the number of files in Android to double check the user didn't select more but we could have this UX improved with iOS at least

@erperejildo on iOS this is easily doable on media picks, however, Files app picks doesn’t provide a way to limit selection as well.

I’m afraid that it may introduce a lot of misusage for developers if the feature is only implemented for some particular types.

For example, picking paths isn’t supported on the web, and despite having documented it and throwing an error when accessing path property on Flutter Web, there are still people every now and then opening issues because “_it doesn’t work_”.

I want to keep it as simple as possible without having devs confused about whether a particular feature will work on all devices or not, but haven’t come with a clean solution yet — plus, working on this only on my free time, which lately hasn’t been much. 😔

In that case to avoid more questions about this, I'd add this info to the docs

They could do it on Android: https://github.com/sangcomz/FishBun

@kreativityapps that’s by using a 3rd party picker. Not natively, unfortunately.

@miguelpruivo any good news?

Was this page helpful?
0 / 5 - 0 ratings