Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Merge branch 'main' into new-formatter-image-picker
  • Loading branch information
stuartmorgan-g committed Aug 16, 2025
commit b3ae4e2cf261153ff194e818c4d4b7f141e8ab64
7 changes: 6 additions & 1 deletion packages/image_picker/image_picker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
## 1.2.0
## NEXT

* Updates minimum supported SDK version to Flutter 3.29/Dart 3.7.

## 1.2.0

* Adds `pickMultiVideo` to allow selecting multiple videos from the gallery.
* Updates minimum supported SDK version to Flutter 3.27/Dart 3.6.

## 1.1.2

* Adds comment for the limit parameter.
Expand Down
26 changes: 18 additions & 8 deletions packages/image_picker/image_picker/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,19 @@ class _MyHomePageState extends State<MyHomePage> {
}
if (context.mounted) {
if (isVideo) {
final XFile? file = await _picker.pickVideo(
source: source,
maxDuration: const Duration(seconds: 10),
);
await _playVideo(file);
} else if (isMultiImage) {
final List<XFile> files;
if (allowMultiple) {
files = await _picker.pickMultiVideo();
} else {
final XFile? file = await _picker.pickVideo(
source: source,
maxDuration: const Duration(seconds: 10),
);
files = <XFile>[if (file != null) file];
}
// Just play the first file, to keep the example simple.
await _playVideo(files.firstOrNull);
} else if (allowMultiple) {
await _displayPickImageDialog(context, true, (
double? maxWidth,
double? maxHeight,
Expand Down Expand Up @@ -456,8 +463,11 @@ class _MyHomePageState extends State<MyHomePage> {
backgroundColor: Colors.red,
onPressed: () {
isVideo = true;
_onImageButtonPressed(ImageSource.gallery,
context: context, allowMultiple: true);
_onImageButtonPressed(
ImageSource.gallery,
context: context,
allowMultiple: true,
);
},
heroTag: 'multiVideo',
tooltip: 'Pick multiple videos',
Expand Down
10 changes: 2 additions & 8 deletions packages/image_picker/image_picker/lib/image_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,9 @@ class ImagePicker {
///
/// The method can throw a [PlatformException] if the video selection process
/// fails.
Future<List<XFile>> pickMultiVideo({
Duration? maxDuration,
int? limit,
}) {
Future<List<XFile>> pickMultiVideo({Duration? maxDuration, int? limit}) {
return platform.getMultiVideoWithOptions(
options: MultiVideoPickerOptions(
maxDuration: maxDuration,
limit: limit,
),
options: MultiVideoPickerOptions(maxDuration: maxDuration, limit: limit),
);
}

Expand Down
47 changes: 26 additions & 21 deletions packages/image_picker/image_picker/test/image_picker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,9 @@ void main() {

group('#pickMultiVideo', () {
setUp(() {
when(mockPlatform.getMultiVideoWithOptions(
options: anyNamed('options'),
)).thenAnswer((Invocation _) async => <XFile>[]);
when(
mockPlatform.getMultiVideoWithOptions(options: anyNamed('options')),
).thenAnswer((Invocation _) async => <XFile>[]);
});

test('passes the arguments correctly', () async {
Expand All @@ -499,26 +499,31 @@ void main() {

verifyInOrder(<Object>[
mockPlatform.getMultiVideoWithOptions(
options: argThat(
isInstanceOf<MultiVideoPickerOptions>(),
named: 'options',
)),
options: argThat(
isInstanceOf<MultiVideoPickerOptions>(),
named: 'options',
),
),
mockPlatform.getMultiVideoWithOptions(
options: argThat(
isInstanceOf<MultiVideoPickerOptions>().having(
options: argThat(
isInstanceOf<MultiVideoPickerOptions>().having(
(MultiVideoPickerOptions options) => options.maxDuration,
'maxDuration',
equals(const Duration(seconds: 10))),
named: 'options',
)),
equals(const Duration(seconds: 10)),
),
named: 'options',
),
),
mockPlatform.getMultiVideoWithOptions(
options: argThat(
isInstanceOf<MultiVideoPickerOptions>().having(
options: argThat(
isInstanceOf<MultiVideoPickerOptions>().having(
(MultiVideoPickerOptions options) => options.limit,
'limit',
equals(5)),
named: 'options',
)),
equals(5),
),
named: 'options',
),
),
]);
});
});
Expand Down Expand Up @@ -646,9 +651,9 @@ void main() {
)
.having(
(MultiImagePickerOptions options) =>
options.imageOptions.maxHeight,
options.imageOptions.maxWidth,
'maxHeight',
equals(20.0),
equals(10.0),
)
.having(
(MultiImagePickerOptions options) =>
Expand All @@ -670,9 +675,9 @@ void main() {
)
.having(
(MultiImagePickerOptions options) =>
options.imageOptions.maxHeight,
options.imageOptions.maxWidth,
'maxHeight',
equals(20.0),
equals(10.0),
)
.having(
(MultiImagePickerOptions options) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,18 @@ class MockImagePickerPlatform extends _i1.Mock
)
as _i4.Future<List<_i5.XFile>>);

@override
_i4.Future<List<_i5.XFile>> getMultiVideoWithOptions({
_i2.MultiVideoPickerOptions? options = const _i2.MultiVideoPickerOptions(),
}) =>
(super.noSuchMethod(
Invocation.method(#getMultiVideoWithOptions, [], {
#options: options,
}),
returnValue: _i4.Future<List<_i5.XFile>>.value(<_i5.XFile>[]),
)
as _i4.Future<List<_i5.XFile>>);

@override
bool supportsImageSource(_i2.ImageSource? source) =>
(super.noSuchMethod(
Expand Down
4 changes: 4 additions & 0 deletions packages/image_picker/image_picker_android/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

* Updates minimum supported SDK version to Flutter 3.29/Dart 3.7.

## 0.8.13

* Adds support for `getMultiVideoWithOptions`.

## 0.8.12+25

* Updates kotlin version to 2.2.0 to enable gradle 8.11 support.
Expand Down
42 changes: 26 additions & 16 deletions packages/image_picker/image_picker_android/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ class _MyHomePageState extends State<MyHomePage> {
Future<void> _playVideo(XFile? file) async {
if (file != null && mounted) {
await _disposeVideoController();
final VideoPlayerController controller =
VideoPlayerController.file(File(file.path));
final VideoPlayerController controller = VideoPlayerController.file(
File(file.path),
);
_controller = controller;
await controller.setVolume(1.0);
await controller.initialize();
Expand All @@ -101,15 +102,22 @@ class _MyHomePageState extends State<MyHomePage> {
}
if (context.mounted) {
if (_isVideo) {
final XFile? file = await _picker.getVideo(
source: source,
maxDuration: const Duration(seconds: 10),
);
if (file != null && context.mounted) {
_showPickedSnackBar(context, <XFile>[file]);
final List<XFile> files;
if (allowMultiple) {
files = await _picker.getMultiVideoWithOptions();
} else {
final XFile? file = await _picker.getVideo(
source: source,
maxDuration: const Duration(seconds: 10),
);
files = <XFile>[if (file != null) file];
}
await _playVideo(file);
} else if (isMultiImage) {
if (files.isNotEmpty && context.mounted) {
_showPickedSnackBar(context, files);
// Just play the first file, to keep the example simple.
await _playVideo(files.first);
}
} else if (allowMultiple) {
await _displayPickImageDialog(context, true, (
double? maxWidth,
double? maxHeight,
Expand All @@ -126,7 +134,7 @@ class _MyHomePageState extends State<MyHomePage> {
isMedia
? await _picker.getMedia(
options: MediaOptions(
allowMultiple: isMultiImage,
allowMultiple: allowMultiple,
imageOptions: imageOptions,
limit: limit,
),
Expand Down Expand Up @@ -161,7 +169,7 @@ class _MyHomePageState extends State<MyHomePage> {
final XFile? media = _firstOrNull(
await _picker.getMedia(
options: MediaOptions(
allowMultiple: isMultiImage,
allowMultiple: allowMultiple,
imageOptions: ImageOptions(
maxWidth: maxWidth,
maxHeight: maxHeight,
Expand Down Expand Up @@ -313,8 +321,7 @@ class _MyHomePageState extends State<MyHomePage> {
final VideoPlayerController controller = VideoPlayerController.file(
File(_mediaFileList![index].path),
);
const double volume = 1.0;
controller.setVolume(volume);
controller.setVolume(1.0);
controller.initialize();
controller.setLooping(true);
controller.play();
Expand Down Expand Up @@ -495,8 +502,11 @@ class _MyHomePageState extends State<MyHomePage> {
backgroundColor: Colors.red,
onPressed: () {
_isVideo = true;
_onImageButtonPressed(ImageSource.gallery,
context: context, allowMultiple: true);
_onImageButtonPressed(
ImageSource.gallery,
context: context,
allowMultiple: true,
);
},
heroTag: 'multiVideo',
tooltip: 'Pick multiple videos',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,10 +614,11 @@ void main() {
test('passes the arguments correctly', () async {
api.returnValue = <String>[];
await picker.getMultiVideoWithOptions(
options: const MultiVideoPickerOptions(
maxDuration: Duration(seconds: 10),
limit: 5,
));
options: const MultiVideoPickerOptions(
maxDuration: Duration(seconds: 10),
limit: 5,
),
);

expect(api.passedSource?.type, SourceType.gallery);
expect(api.passedVideoOptions?.maxDurationSeconds, 10);
Expand Down
7 changes: 6 additions & 1 deletion packages/image_picker/image_picker_for_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
## 3.1.0
## NEXT

* Updates minimum supported SDK version to Flutter 3.29/Dart 3.7.

## 3.1.0

* Adds support for `getMultiVideoWithOptions`.
* Updates minimum supported SDK version to Flutter 3.27/Dart 3.6.

## 3.0.6

* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ void main() {
testWidgets('getMultiVideoWithOptions can select multiple files', (
WidgetTester _,
) async {
final web.HTMLInputElement mockInput = web.HTMLInputElement()
..type = 'file';
final web.HTMLInputElement mockInput =
web.HTMLInputElement()..type = 'file';

final ImagePickerPluginTestOverrides overrides =
ImagePickerPluginTestOverrides()
Expand Down
8 changes: 7 additions & 1 deletion packages/image_picker/image_picker_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
## 0.8.13
## NEXT

* Updates minimum supported SDK version to Flutter 3.29/Dart 3.7.

## 0.8.13

* Adds support for `getMultiVideoWithOptions`.
* Updates minimum supported SDK version to Flutter 3.27/Dart 3.6.
* Adds photo to Photos library during test to support iOS 26.

## 0.8.12+2

* Removes the need for user permissions to pick an image on iOS 14+.
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.