Skip to content

Conversation

hgraceb
Copy link
Member

@hgraceb hgraceb commented Oct 8, 2025

Pre-Review Checklist

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly fixes a typo in an error message across three different files. Thank you for improving the user-facing strings!

I've added a few comments regarding code duplication for the error message that this change highlights. Consolidating the error message into a single constant would improve the maintainability of the code. This is a suggestion for improvement and not a blocker for this PR.


if (limit != null && limit < 2) {
throw ArgumentError.value(limit, 'limit', 'cannot be lower then 2');
throw ArgumentError.value(limit, 'limit', 'cannot be lower than 2');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This is another location where the duplicated error message is fixed. To improve long-term maintainability, it would be best to use a shared constant for this message. Please see my comment in packages/image_picker/image_picker_platform_interface/lib/src/types/multi_image_picker_options.dart for a more detailed suggestion.


if (limit != null && limit < 2) {
throw ArgumentError.value(limit, 'limit', 'cannot be lower then 2');
throw ArgumentError.value(limit, 'limit', 'cannot be lower than 2');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This is another instance of the duplicated error message. To improve maintainability, please consider using a shared constant. I've left a more detailed comment on this topic in packages/image_picker/image_picker_platform_interface/lib/src/types/multi_image_picker_options.dart.

static void _validate({int? limit}) {
if (limit != null && limit < 2) {
throw ArgumentError.value(limit, 'limit', 'cannot be lower then 2');
throw ArgumentError.value(limit, 'limit', 'cannot be lower than 2');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While fixing the typo is correct, this change highlights that the error message string is duplicated in multiple files (multi_image_picker_options.dart, media_options.dart, and image_picker_android.dart).

To improve maintainability and adhere to the DRY (Don't Repeat Yourself) principle, it's better to define this string as a constant in one place and reuse it. This prevents future inconsistencies where a fix might be missed in one of the locations.

A possible approach:

  1. Define a public constant in a suitable location within the image_picker_platform_interface package, for example, at the top level of this file:
    const String kLimitLowerThanTwoError = 'cannot be lower than 2';
  2. Use this constant kLimitLowerThanTwoError in all three files where this error is thrown.

@stuartmorgan-g
Copy link
Collaborator

This change is not test exempt; messages thrown outside of the package are part of the public surface, and this is a bug in that surface.

There are already tests of the cases that throws these errors; they should be augmented to check that the message is correct (like this).

Copy link
Member

@gmackall gmackall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

android portion lgtm

@hgraceb
Copy link
Member Author

hgraceb commented Oct 9, 2025

The Linux repo_checks message says, "Dart changes are not allowed to other packages in image_picker in the same PR as changes to public Dart code in image_picker_platform_interface." Should I split the current PR into multiple ones?

@stuartmorgan-g
Copy link
Collaborator

Should I split the current PR into multiple ones?

Yes, it will need to be two PRs; we don't allow bypassing that check, for safety reasons.

Comment on lines 785 to 793
throwsA(
isA<ArgumentError>()
.having((ArgumentError error) => error.name, 'name', 'limit')
.having(
(ArgumentError error) => error.message,
'message',
'cannot be lower than 2',
),
),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't aware of this before I just checked, but these "throwsA" calls can be stored in a variable, so you don't need to repeat them multiple times in every file.

I'm not sure what the design rules are for that though. Maybe @stuartmorgan-g knows?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've stored the duplicate code in a local variable, and I'm happy to make changes if there's a better way to handle it.

@hgraceb hgraceb changed the title [image_picker] Fix typos in error messages [image_picker] Fix typos in error messages for android Oct 11, 2025
@hgraceb
Copy link
Member Author

hgraceb commented Oct 11, 2025

I split the code outside of the Android and iOS module into #10211.

@hgraceb hgraceb changed the title [image_picker] Fix typos in error messages for android [image_picker] Fix typos in error messages for Android and iOS Oct 11, 2025
@hgraceb hgraceb changed the title [image_picker] Fix typos in error messages for Android and iOS [image_picker] Fix typos in error messages for android Oct 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants