diff --git a/packages/image_picker/image_picker_android/CHANGELOG.md b/packages/image_picker/image_picker_android/CHANGELOG.md index ca92f48f27d..f7bbb4f67bd 100644 --- a/packages/image_picker/image_picker_android/CHANGELOG.md +++ b/packages/image_picker/image_picker_android/CHANGELOG.md @@ -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. diff --git a/packages/image_picker/image_picker_android/lib/image_picker_android.dart b/packages/image_picker/image_picker_android/lib/image_picker_android.dart index 5316a6a089e..fd7080f536b 100644 --- a/packages/image_picker/image_picker_android/lib/image_picker_android.dart +++ b/packages/image_picker/image_picker_android/lib/image_picker_android.dart @@ -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'); } return GeneralOptions( diff --git a/packages/image_picker/image_picker_android/pubspec.yaml b/packages/image_picker/image_picker_android/pubspec.yaml index 4014bcd5d42..cff3b83c248 100755 --- a/packages/image_picker/image_picker_android/pubspec.yaml +++ b/packages/image_picker/image_picker_android/pubspec.yaml @@ -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 diff --git a/packages/image_picker/image_picker_android/test/image_picker_android_test.dart b/packages/image_picker/image_picker_android/test/image_picker_android_test.dart index 624858223d5..53a8a09c01b 100644 --- a/packages/image_picker/image_picker_android/test/image_picker_android_test.dart +++ b/packages/image_picker/image_picker_android/test/image_picker_android_test.dart @@ -778,18 +778,35 @@ void main() { }); test('does not accept an invalid limit argument', () { + final Matcher throwsLimitArgumentError = throwsA( + isA() + .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, ); }); diff --git a/packages/image_picker/image_picker_ios/test/image_picker_ios_test.dart b/packages/image_picker/image_picker_ios/test/image_picker_ios_test.dart index 3a1ab29b830..2b8edac2bf9 100644 --- a/packages/image_picker/image_picker_ios/test/image_picker_ios_test.dart +++ b/packages/image_picker/image_picker_ios/test/image_picker_ios_test.dart @@ -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, @@ -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, @@ -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, @@ -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 = ['0', '1']; expect(() => picker.getMultiImage(imageQuality: -1), throwsArgumentError); @@ -1214,7 +1214,7 @@ void main() { ); }); - test('does not accept a invalid imageQuality argument', () { + test('does not accept an invalid imageQuality argument', () { log.returnValue = ['0', '1']; expect( () => picker.getMedia( @@ -1237,20 +1237,37 @@ void main() { ); }); - test('does not accept a invalid limit argument', () { + test('does not accept an invalid limit argument', () { log.returnValue = ['0', '1']; + final Matcher throwsLimitArgumentError = throwsA( + isA() + .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, ); }); @@ -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, @@ -1881,7 +1898,7 @@ void main() { ); }); - test('does not accept a invalid imageQuality argument', () { + test('does not accept an invalid imageQuality argument', () { log.returnValue = ['0', '1']; expect( () => picker.getMultiImageWithOptions( @@ -1902,20 +1919,37 @@ void main() { ); }); - test('does not accept a invalid limit argument', () { + test('does not accept an invalid limit argument', () { log.returnValue = ['0', '1']; + final Matcher throwsLimitArgumentError = throwsA( + isA() + .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, ); });