Skip to content

Commit f34184e

Browse files
[camera] Deprecate maxDuration in platform interface (flutter#7078)
Platform interface portion of flutter/packages#7039 Part of flutter#150959
1 parent edb38e0 commit f34184e

File tree

5 files changed

+16
-37
lines changed

5 files changed

+16
-37
lines changed

packages/camera/camera_platform_interface/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
## NEXT
1+
## 2.8.0
22

3+
* Deprecates `maxVideoDuration`/`maxDuration`, as it was never implemented on
4+
most platforms, and there is no plan to implement it in the future.
35
* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2.
46

57
## 2.7.4

packages/camera/camera_platform_interface/lib/src/platform_interface/camera_platform.dart

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,13 @@ abstract class CameraPlatform extends PlatformInterface {
140140

141141
/// Starts a video recording.
142142
///
143-
/// The length of the recording can be limited by specifying the [maxVideoDuration].
144-
/// By default no maximum duration is specified,
145-
/// meaning the recording will continue until manually stopped.
146-
/// With [maxVideoDuration] set the video is returned in a [VideoRecordedEvent]
147-
/// through the [onVideoRecordedEvent] stream when the set duration is reached.
148-
///
149143
/// This method is deprecated in favour of [startVideoCapturing].
150-
Future<void> startVideoRecording(int cameraId, {Duration? maxVideoDuration}) {
144+
Future<void> startVideoRecording(
145+
int cameraId, {
146+
@Deprecated(
147+
'This parameter is unused, and will be ignored on all platforms')
148+
Duration? maxVideoDuration,
149+
}) {
151150
throw UnimplementedError('startVideoRecording() is not implemented.');
152151
}
153152

@@ -156,8 +155,7 @@ abstract class CameraPlatform extends PlatformInterface {
156155
/// Please see [VideoCaptureOptions] for documentation on the
157156
/// configuration options.
158157
Future<void> startVideoCapturing(VideoCaptureOptions options) {
159-
return startVideoRecording(options.cameraId,
160-
maxVideoDuration: options.maxDuration);
158+
return startVideoRecording(options.cameraId);
161159
}
162160

163161
/// Stops the video recording and returns the file where it was saved.

packages/camera/camera_platform_interface/lib/src/types/video_capture_options.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class VideoCaptureOptions {
1212
/// Constructs a new instance.
1313
const VideoCaptureOptions(
1414
this.cameraId, {
15+
@Deprecated(
16+
'This parameter is unused, and will be ignored on all platforms')
1517
this.maxDuration,
1618
this.streamCallback,
1719
this.streamOptions,
@@ -24,8 +26,9 @@ class VideoCaptureOptions {
2426
final int cameraId;
2527

2628
/// The maximum time to perform capturing for.
27-
///
28-
/// By default there is no maximum on the capture time.
29+
@Deprecated('This parameter is unused, and will be ignored on all platforms')
30+
// Platform implementations should not implement this, as it will never be
31+
// passed from the app-facing layer.
2932
final Duration? maxDuration;
3033

3134
/// An optional callback to enable streaming.

packages/camera/camera_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/camera/camera
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%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.7.4
7+
version: 2.8.0
88

99
environment:
1010
sdk: ^3.2.0

packages/camera/camera_platform_interface/test/method_channel/method_channel_camera_test.dart

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -643,30 +643,6 @@ void main() {
643643
]);
644644
});
645645

646-
test('Should pass maxVideoDuration when starting recording a video',
647-
() async {
648-
// Arrange
649-
final MethodChannelMock channel = MethodChannelMock(
650-
channelName: 'plugins.flutter.io/camera',
651-
methods: <String, dynamic>{'startVideoRecording': null},
652-
);
653-
654-
// Act
655-
await camera.startVideoRecording(
656-
cameraId,
657-
maxVideoDuration: const Duration(seconds: 10),
658-
);
659-
660-
// Assert
661-
expect(channel.log, <Matcher>[
662-
isMethodCall('startVideoRecording', arguments: <String, Object?>{
663-
'cameraId': cameraId,
664-
'maxVideoDuration': 10000,
665-
'enableStream': false,
666-
}),
667-
]);
668-
});
669-
670646
test('Should stop a video recording and return the file', () async {
671647
// Arrange
672648
final MethodChannelMock channel = MethodChannelMock(

0 commit comments

Comments
 (0)