Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 7a63dbc

Browse files
[camera] flip/change camera while recording - platform interface (#7011)
* platform interface changes pr * changes version to 2.4 * fixes versioning --------- Co-authored-by: BradenBagby <[email protected]>
1 parent 8838645 commit 7a63dbc

File tree

5 files changed

+43
-2
lines changed

5 files changed

+43
-2
lines changed

packages/camera/camera_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.4.0
22

3+
* Allows camera to be switched while video recording.
34
* Updates minimum Flutter version to 3.0.
45

56
## 2.3.4

packages/camera/camera_platform_interface/lib/src/method_channel/method_channel_camera.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,17 @@ class MethodChannelCamera extends CameraPlatform {
504504
);
505505
}
506506

507+
@override
508+
Future<void> setDescriptionWhileRecording(
509+
CameraDescription description) async {
510+
await _channel.invokeMethod<double>(
511+
'setDescriptionWhileRecording',
512+
<String, dynamic>{
513+
'cameraName': description.name,
514+
},
515+
);
516+
}
517+
507518
@override
508519
Widget buildPreview(int cameraId) {
509520
return Texture(textureId: cameraId);

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,12 @@ abstract class CameraPlatform extends PlatformInterface {
269269
throw UnimplementedError('pausePreview() is not implemented.');
270270
}
271271

272+
/// Sets the active camera while recording.
273+
Future<void> setDescriptionWhileRecording(CameraDescription description) {
274+
throw UnimplementedError(
275+
'setDescriptionWhileRecording() is not implemented.');
276+
}
277+
272278
/// Returns a widget showing a live camera preview.
273279
Widget buildPreview(int cameraId) {
274280
throw UnimplementedError('buildView() has not been implemented.');

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/plugins/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.3.4
7+
version: 2.4.0
88

99
environment:
1010
sdk: '>=2.12.0 <3.0.0'

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,29 @@ void main() {
576576
]);
577577
});
578578

579+
test('Should set description while recording', () async {
580+
// Arrange
581+
final MethodChannelMock channel = MethodChannelMock(
582+
channelName: 'plugins.flutter.io/camera',
583+
methods: <String, dynamic>{'setDescriptionWhileRecording': null},
584+
);
585+
586+
// Act
587+
const CameraDescription cameraDescription = CameraDescription(
588+
name: 'Test',
589+
lensDirection: CameraLensDirection.back,
590+
sensorOrientation: 0);
591+
await camera.setDescriptionWhileRecording(cameraDescription);
592+
593+
// Assert
594+
expect(channel.log, <Matcher>[
595+
isMethodCall('setDescriptionWhileRecording',
596+
arguments: <String, Object?>{
597+
'cameraName': cameraDescription.name
598+
}),
599+
]);
600+
});
601+
579602
test('Should pass maxVideoDuration when starting recording a video',
580603
() async {
581604
// Arrange

0 commit comments

Comments
 (0)