packages icon indicating copy to clipboard operation
packages copied to clipboard

[image_picker] Add limit parameter to pickMultiImage and pickMultipleMedia to ios and Android

Open pdenert opened this issue 1 year ago • 6 comments

Adds limit parameter to MediaOptions and MultiImagePickerOptions and supports its use on iOS and Android. The limit argument defines how many images or media files can be select.

Fixes: flutter/flutter#85772

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

pdenert avatar Feb 25 '24 03:02 pdenert

I've cleaned up packages which remain unchanged. I've removed limit from deprecated methods. I've updated iOS and Android implementations

pdenert avatar Feb 29 '24 02:02 pdenert

Thanks for reverting the web package @pdenert!

I checked the web APIs again and there's nothing new to limit the number of files that the user selects (as in: disable file selection once the user selects limit files).

We could count how many they've selected and throw an exception, or discard extras if they've picked too many, but that's probably confusing, and can be implemented on the application layer too.

ditman avatar Feb 29 '24 03:02 ditman

We could count how many they've selected and throw an exception, or discard extras if they've picked too many, but that's probably confusing, and can be implemented on the application layer too.

Yeah, I feel the same way. If we can't limit choice on the UI side, then it's better to do nothing.

pdenert avatar Feb 29 '24 10:02 pdenert

@tarrinneal do you mind look at this again?

pdenert avatar Mar 04 '24 14:03 pdenert

@vashworth thanks for the test examples. I've also added tests for variants where the limit is nil

pdenert avatar Mar 04 '24 23:03 pdenert

Also, the existing tests will need to have the limit parameter added where needed... I think some of them should be failing as is? See this test, for example, which should certainly fail without the new limit parameter. cc @stuartmorgan do you happen to know if these tests aren't running as part of pre-submit?

Native unit tests are the step after lint in android_platform_tests, and CI stops after failures unless we explicitly tell it not to, so currently any failures in native unit tests would be masked by the lint failure.

stuartmorgan-g avatar Mar 13 '24 16:03 stuartmorgan-g

@gmackall I've extracted getting final limit to getLimitFromOptions in ImagePickerUtils and suppressed the lint warning. I've also updated the native tests and added new ones for limit

pdenert avatar Mar 19 '24 09:03 pdenert

Quick review of the platform interface. I'll try to get a full review in asap for you.

@tarrinneal hey, may you add your full review soon?

pdenert avatar Mar 20 '24 09:03 pdenert

Quick review of the platform interface. I'll try to get a full review in asap for you.

@tarrinneal hey, may you add your full review soon?

@tarrinneal just friendly reminder that I'm still waiting for review

pdenert avatar Mar 27 '24 19:03 pdenert

Sorry for the delays.

This seems ready to break up into it's respective pr's as per https://github.com/flutter/flutter/wiki/Contributing-to-Plugins-and-Packages#changing-federated-plugins

Let me know if you need help with any of this.

tarrinneal avatar Mar 27 '24 19:03 tarrinneal

PR with platform interface changes only is ready here: https://github.com/flutter/packages/pull/6434

pdenert avatar Mar 28 '24 23:03 pdenert

@tarrinneal I have updated the PR to the published platform interface changes

pdenert avatar Apr 09 '24 11:04 pdenert

@tarrinneal may you look at this soon?

pdenert avatar Apr 16 '24 14:04 pdenert