Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## NEXT
## 2.11.1

* Updates minimum supported SDK version to Flutter 3.29/Dart 3.7.
* Fixes typo in limit parameter validation error messages.

## 2.11.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class MediaOptions {
}

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');
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MultiImagePickerOptions {
/// Throws if limit is lower than 2.
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');
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/image_picker/
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 2.11.0
version: 2.11.1

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

test('createAndValidate throw error for to small limit', () {
test('createAndValidate throws error for too small limit', () {
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(
() => MediaOptions.createAndValidate(allowMultiple: true, limit: 1),
throwsArgumentError,
throwsLimitArgumentError,
);
expect(
() => MediaOptions.createAndValidate(allowMultiple: true, limit: 0),
throwsArgumentError,
throwsLimitArgumentError,
);
expect(
() => MediaOptions.createAndValidate(allowMultiple: true, limit: -1),
throwsArgumentError,
throwsLimitArgumentError,
);
});

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

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

test('does not accept a invalid limit argument', () {
test('does not accept an invalid limit argument', () {
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',
),
);
Comment on lines +1101 to +1109

Choose a reason for hiding this comment

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

medium

This throwsLimitArgumentError matcher is also defined in the test for getMultiImageWithOptions around line 1841. To improve maintainability and avoid code duplication, consider defining this matcher once at the top level of the file and reusing it in both tests.


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

expect(
Expand All @@ -1115,7 +1125,17 @@ void main() {
limit: 0,
),
),
throwsArgumentError,
throwsLimitArgumentError,
);

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

Expand Down Expand Up @@ -1816,25 +1836,35 @@ void main() {

test('does not accept an invalid limit argument', () {
returnValue = <dynamic>['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: MultiImagePickerOptions.createAndValidate(limit: -1),
),
throwsArgumentError,
throwsLimitArgumentError,
);

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,28 @@ void main() {
);
});

test('createAndValidate throw error for to small limit', () {
test('createAndValidate throws error for too small limit', () {
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(
() => MultiImagePickerOptions.createAndValidate(limit: 1),
throwsArgumentError,
throwsLimitArgumentError,
);
expect(
() => MultiImagePickerOptions.createAndValidate(limit: 0),
throwsArgumentError,
throwsLimitArgumentError,
);
expect(
() => MultiImagePickerOptions.createAndValidate(limit: -1),
throwsArgumentError,
throwsLimitArgumentError,
);
});
});
Expand Down