Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/image_picker/image_picker_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.8.13+6

* Fixes typo in limit parameter validation error message.

## 0.8.13+5

* Updates Java compatibility version to 17 and minimum supported SDK version to Flutter 3.35/Dart 3.9.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class ImagePickerAndroid extends ImagePickerPlatform {
}

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.

}

return GeneralOptions(
Expand Down
2 changes: 1 addition & 1 deletion packages/image_picker/image_picker_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: image_picker_android
description: Android implementation of the image_picker plugin.
repository: https://github.com/flutter/packages/tree/main/packages/image_picker/image_picker_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22
version: 0.8.13+5
version: 0.8.13+6

environment:
sdk: ^3.9.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,18 +778,35 @@ void main() {
});

test('does not accept an invalid limit argument', () {
final Matcher throwsLimitArgumentError = throwsA(
isA<ArgumentError>()
.having((ArgumentError error) => error.name, 'name', 'limit')
.having(
(ArgumentError error) => error.message,
'message',
'cannot be lower than 2',
),
);

expect(
() => picker.getMedia(
options: const MediaOptions(allowMultiple: true, limit: -1),
),
throwsArgumentError,
throwsLimitArgumentError,
);

expect(
() => picker.getMedia(
options: const MediaOptions(allowMultiple: true, limit: 0),
),
throwsArgumentError,
throwsLimitArgumentError,
);

expect(
() => picker.getMedia(
options: const MediaOptions(allowMultiple: true, limit: 1),
),
throwsLimitArgumentError,
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ void main() {
]);
});

test('does not accept a invalid imageQuality argument', () {
test('does not accept an invalid imageQuality argument', () {
expect(
() => picker.pickImage(imageQuality: -1, source: ImageSource.gallery),
throwsArgumentError,
Expand Down Expand Up @@ -487,7 +487,7 @@ void main() {
expect(() => picker.pickMultiImage(maxHeight: -1.0), throwsArgumentError);
});

test('does not accept a invalid imageQuality argument', () {
test('does not accept an invalid imageQuality argument', () {
expect(
() => picker.pickMultiImage(imageQuality: -1),
throwsArgumentError,
Expand Down Expand Up @@ -760,7 +760,7 @@ void main() {
]);
});

test('does not accept a invalid imageQuality argument', () {
test('does not accept an invalid imageQuality argument', () {
expect(
() => picker.getImage(imageQuality: -1, source: ImageSource.gallery),
throwsArgumentError,
Expand Down Expand Up @@ -955,7 +955,7 @@ void main() {
expect(() => picker.getMultiImage(maxHeight: -1.0), throwsArgumentError);
});

test('does not accept a invalid imageQuality argument', () {
test('does not accept an invalid imageQuality argument', () {
log.returnValue = <String>['0', '1'];
expect(() => picker.getMultiImage(imageQuality: -1), throwsArgumentError);

Expand Down Expand Up @@ -1214,7 +1214,7 @@ void main() {
);
});

test('does not accept a invalid imageQuality argument', () {
test('does not accept an invalid imageQuality argument', () {
log.returnValue = <String>['0', '1'];
expect(
() => picker.getMedia(
Expand All @@ -1237,20 +1237,37 @@ void main() {
);
});

test('does not accept a invalid limit argument', () {
test('does not accept an invalid limit argument', () {
log.returnValue = <String>['0', '1'];
final Matcher throwsLimitArgumentError = throwsA(
isA<ArgumentError>()
.having((ArgumentError error) => error.name, 'name', 'limit')
.having(
(ArgumentError error) => error.message,
'message',
'cannot be lower than 2',
),
);

expect(
() => picker.getMedia(
options: const MediaOptions(allowMultiple: true, limit: -1),
),
throwsArgumentError,
throwsLimitArgumentError,
);

expect(
() => picker.getMedia(
options: const MediaOptions(allowMultiple: true, limit: 0),
),
throwsArgumentError,
throwsLimitArgumentError,
);

expect(
() => picker.getMedia(
options: const MediaOptions(allowMultiple: true, limit: 1),
),
throwsLimitArgumentError,
);
});

Expand Down Expand Up @@ -1563,7 +1580,7 @@ void main() {
]);
});

test('does not accept a invalid imageQuality argument', () {
test('does not accept an invalid imageQuality argument', () {
expect(
() => picker.getImageFromSource(
source: ImageSource.gallery,
Expand Down Expand Up @@ -1881,7 +1898,7 @@ void main() {
);
});

test('does not accept a invalid imageQuality argument', () {
test('does not accept an invalid imageQuality argument', () {
log.returnValue = <String>['0', '1'];
expect(
() => picker.getMultiImageWithOptions(
Expand All @@ -1902,20 +1919,37 @@ void main() {
);
});

test('does not accept a invalid limit argument', () {
test('does not accept an invalid limit argument', () {
log.returnValue = <String>['0', '1'];
final Matcher throwsLimitArgumentError = throwsA(
isA<ArgumentError>()
.having((ArgumentError error) => error.name, 'name', 'limit')
.having(
(ArgumentError error) => error.message,
'message',
'cannot be lower than 2',
),
);

expect(
() => picker.getMultiImageWithOptions(
options: const MultiImagePickerOptions(limit: -1),
),
throwsArgumentError,
throwsLimitArgumentError,
);

expect(
() => picker.getMultiImageWithOptions(
options: const MultiImagePickerOptions(limit: 0),
),
throwsArgumentError,
throwsLimitArgumentError,
);

expect(
() => picker.getMultiImageWithOptions(
options: const MultiImagePickerOptions(limit: 1),
),
throwsLimitArgumentError,
);
});

Expand Down