flutter_file_picker icon indicating copy to clipboard operation
flutter_file_picker copied to clipboard

Files number limit

Open AshrafLP opened this issue 4 years ago • 24 comments

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.

AshrafLP avatar Sep 14 '20 08:09 AshrafLP

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.

miguelpruivo avatar Sep 14 '20 08:09 miguelpruivo

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.

miguelpruivo avatar Oct 04 '20 20:10 miguelpruivo

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

AshrafLP avatar Oct 04 '20 21:10 AshrafLP

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

syssam avatar Oct 18 '20 13:10 syssam

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 avatar Oct 25 '20 15:10 miguelpruivo

@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!

syssam avatar Oct 26 '20 01:10 syssam

@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 avatar Nov 17 '20 14:11 erperejildo

@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. 😔

miguelpruivo avatar Nov 18 '20 00:11 miguelpruivo

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

erperejildo avatar Nov 18 '20 09:11 erperejildo

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

kreativityapps avatar Nov 18 '20 11:11 kreativityapps

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

miguelpruivo avatar Nov 18 '20 11:11 miguelpruivo

@miguelpruivo any good news?

syssam avatar Dec 29 '20 12:12 syssam

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 wonder if this might be a good place for a custom builder option? Let the dev have a way to build said message?

I know it could be done already but it would be convenient to have a builder option that is automatically called if/when the single file picker is used.

You could also make it a different init function. Like

FilePicker.platform.pickFile

And make the message required to init the single pick mode. That way it draws attention to the dev about what is happening / they can't get a new instance without providing the message for Android.

kenthinson avatar Jun 04 '21 08:06 kenthinson

@miguelpruivo I'm curious what your thoughts are on my proposed solution? Thanks for your time.

kenthinson avatar Jun 10 '21 00:06 kenthinson

@kenthinson well, I've started this a couple of times but I believe there is not "clean" way to do so other than creating a custom picker — which I don't want to. I follow the native platform pickers along with their own capabilities, that's one of the main features of this plugin. However, the only way I can see this being done across all platforms is by discarding and showing an error after picking the N+ files, however, this can be easily done when needed by the dev, hence, I still don't have a clue whether or not this should be implemented.

I'm open to any ideas.

miguelpruivo avatar Jun 22 '21 10:06 miguelpruivo

Any updates on this ?

luvishq avatar Jan 03 '22 01:01 luvishq

Hi, unfortunately no. I don’t believe there is a easy way to do this natively.

miguelpruivo avatar Jan 03 '22 10:01 miguelpruivo

Hi, How the WhatsApp restrict the max of 30 files, how we use this restriction and max of 5.

SHAKTHI62 avatar Aug 23 '22 08:08 SHAKTHI62

@miguelpruivo from what I understand there is a newer Android Photo Picker API that let you set a max items limit.

Maybe you can add this only for media/photos/video options.

hectorAguero avatar Apr 12 '23 11:04 hectorAguero

Any update on this feature?

ankitgadatc avatar Dec 04 '23 05:12 ankitgadatc

This is a high priority feature, but I don't have any ETA since I haven't much time to work on this. Any help would be appreciated. ♥️

miguelpruivo avatar Mar 20 '24 10:03 miguelpruivo

Looking forward to this feature🥹

llli0v0 avatar Mar 24 '24 06:03 llli0v0