Skip to content

Commit 1ef6b58

Browse files
[image_picker] Add the ability to pick multiple videos - platform_interface (#9804)
This is the platform interface portion of #9775 Part of flutter/flutter#102283 ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^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.
1 parent 09533b7 commit 1ef6b58

File tree

6 files changed

+54
-2
lines changed

6 files changed

+54
-2
lines changed

packages/image_picker/image_picker_platform_interface/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 2.11.0
22

3+
* Adds `getMultiVideoWithOptions` method.
34
* Updates minimum supported SDK version to Flutter 3.27/Dart 3.6.
45

56
## 2.10.1

packages/image_picker/image_picker_platform_interface/lib/src/platform_interface/image_picker_platform.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,21 @@ abstract class ImagePickerPlatform extends PlatformInterface {
322322
return pickedImages ?? <XFile>[];
323323
}
324324

325+
/// Returns a [List<XFile>] with the videos that were picked.
326+
///
327+
/// The videos come from the [ImageSource.gallery].
328+
///
329+
/// The `options` argument controls additional settings that can be used when
330+
/// picking a video. See [MultiVideoPickerOptions] for more details.
331+
///
332+
/// If no videos were picked, returns an empty list.
333+
Future<List<XFile>> getMultiVideoWithOptions({
334+
MultiVideoPickerOptions options = const MultiVideoPickerOptions(),
335+
}) {
336+
throw UnimplementedError(
337+
'getMultiVideoWithOptions() has not been implemented.');
338+
}
339+
325340
/// Returns true if the implementation supports [source].
326341
///
327342
/// Defaults to true for the original image sources, `gallery` and `camera`,
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter/foundation.dart';
6+
7+
/// Specifies options for picking multiple videos.
8+
@immutable
9+
class MultiVideoPickerOptions {
10+
/// Creates an instance with the given options.
11+
const MultiVideoPickerOptions({
12+
this.maxDuration,
13+
this.limit,
14+
});
15+
16+
/// The maximum duration of the picked video.
17+
final Duration? maxDuration;
18+
19+
/// The maximum number of videos that can be selected.
20+
///
21+
/// This value may be ignored by platforms that cannot support it.
22+
final int? limit;
23+
}

packages/image_picker/image_picker_platform_interface/lib/src/types/types.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export 'lost_data_response.dart';
1010
export 'media_options.dart';
1111
export 'media_selection_type.dart';
1212
export 'multi_image_picker_options.dart';
13+
export 'multi_video_picker_options.dart';
1314
export 'picked_file/picked_file.dart';
1415
export 'retrieve_type.dart';
1516

packages/image_picker/image_picker_platform_interface/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/image_picker/
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22
55
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
66
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
7-
version: 2.10.1
7+
version: 2.11.0
88

99
environment:
1010
sdk: ^3.6.0

packages/image_picker/image_picker_platform_interface/test/image_picker_platform_test.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ void main() {
7676
fakePath);
7777
});
7878
});
79+
80+
test(
81+
'Default implementation of getMultiVideoWithOptions should throw '
82+
'unimplemented error', () {
83+
final FakeCameraDelegatingImagePickerPlatform implementation =
84+
FakeCameraDelegatingImagePickerPlatform();
85+
86+
expect(
87+
() => implementation.getMultiVideoWithOptions(),
88+
throwsUnimplementedError,
89+
);
90+
});
7991
}
8092

8193
class FakeImagePickerPlatform extends ImagePickerPlatform {}

0 commit comments

Comments
 (0)