Skip to content

[image_picker] Do not error if a limit of 1 is passed to pickMultiImage #187347

Description

@Wes1324

What package does this bug report belong to?

image_picker

What target platforms are you seeing this bug on?

iOS, Android

Have you already upgraded your packages?

Yes

Details

Currently the image_picker's pickMultiImage method errors if a limit of 1 is passed to it. I assume this is the case because the intention is for the pickImage method to be used in this case.

If the limit is being calculated at runtime, of course it is simple to check the calculated limit and conditionally invoke either pickImage or pickMultiImage if the limit is 1.

However, this behaviour is not documented anywhere. My app calculates the limit dynamically based on how many images have already been selected. It was only by chance when testing a new feature that I noticed my code was erroring if the limit resolved to 1.

I was wondering if at minimum some documentation around the limit method could be added to the package's README explaining this gotcha.

However, a nicer solution might be to make the package automatically fall back to using the pickImage method if a limit of 1 is passed to the pickMultiImage method. That would minimise the chance of someone's app erroring unexpectedly.

Steps to reproduce

Invoke the pickMultiImage method with a limit of 1

Expected results

The package should handle this scenario gracefully

Actual results

The package throws an error

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilityhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: image_pickerThe Image Picker plugin.packageflutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions