@@ -9,6 +9,7 @@ import 'package:camera_platform_interface/camera_platform_interface.dart';
99import 'package:flutter/foundation.dart' ;
1010import 'package:flutter/material.dart' ;
1111import 'package:flutter/services.dart' ;
12+ import 'package:quiver/core.dart' ;
1213
1314import '../camera.dart' ;
1415
@@ -160,10 +161,10 @@ class CameraValue {
160161 bool ? exposurePointSupported,
161162 bool ? focusPointSupported,
162163 DeviceOrientation ? deviceOrientation,
163- DeviceOrientation ? lockedCaptureOrientation,
164- DeviceOrientation ? recordingOrientation,
164+ Optional < DeviceOrientation > ? lockedCaptureOrientation,
165+ Optional < DeviceOrientation > ? recordingOrientation,
165166 bool ? isPreviewPaused,
166- DeviceOrientation ? previewPauseOrientation,
167+ Optional < DeviceOrientation > ? previewPauseOrientation,
167168 }) {
168169 return CameraValue (
169170 isInitialized: isInitialized ?? this .isInitialized,
@@ -180,12 +181,16 @@ class CameraValue {
180181 exposurePointSupported ?? this .exposurePointSupported,
181182 focusPointSupported: focusPointSupported ?? this .focusPointSupported,
182183 deviceOrientation: deviceOrientation ?? this .deviceOrientation,
183- lockedCaptureOrientation:
184- lockedCaptureOrientation ?? this .lockedCaptureOrientation,
185- recordingOrientation: recordingOrientation ?? this .recordingOrientation,
184+ lockedCaptureOrientation: lockedCaptureOrientation == null
185+ ? this .lockedCaptureOrientation
186+ : lockedCaptureOrientation.orNull,
187+ recordingOrientation: recordingOrientation == null
188+ ? this .recordingOrientation
189+ : recordingOrientation.orNull,
186190 isPreviewPaused: isPreviewPaused ?? this .isPreviewPaused,
187- previewPauseOrientation:
188- previewPauseOrientation ?? this .previewPauseOrientation,
191+ previewPauseOrientation: previewPauseOrientation == null
192+ ? this .previewPauseOrientation
193+ : previewPauseOrientation.orNull,
189194 );
190195 }
191196
@@ -353,8 +358,8 @@ class CameraController extends ValueNotifier<CameraValue> {
353358 await CameraPlatform .instance.pausePreview (_cameraId);
354359 value = value.copyWith (
355360 isPreviewPaused: true ,
356- previewPauseOrientation:
357- value.lockedCaptureOrientation ?? value.deviceOrientation);
361+ previewPauseOrientation: Optional < DeviceOrientation >. of (
362+ value.lockedCaptureOrientation ?? value.deviceOrientation)) ;
358363 } on PlatformException catch (e) {
359364 throw CameraException (e.code, e.message);
360365 }
@@ -367,7 +372,9 @@ class CameraController extends ValueNotifier<CameraValue> {
367372 }
368373 try {
369374 await CameraPlatform .instance.resumePreview (_cameraId);
370- value = value.copyWith (isPreviewPaused: false );
375+ value = value.copyWith (
376+ isPreviewPaused: false ,
377+ previewPauseOrientation: const Optional <DeviceOrientation >.absent ());
371378 } on PlatformException catch (e) {
372379 throw CameraException (e.code, e.message);
373380 }
@@ -498,8 +505,8 @@ class CameraController extends ValueNotifier<CameraValue> {
498505 value = value.copyWith (
499506 isRecordingVideo: true ,
500507 isRecordingPaused: false ,
501- recordingOrientation:
502- value.lockedCaptureOrientation ?? value.deviceOrientation);
508+ recordingOrientation: Optional < DeviceOrientation >. of (
509+ value.lockedCaptureOrientation ?? value.deviceOrientation)) ;
503510 } on PlatformException catch (e) {
504511 throw CameraException (e.code, e.message);
505512 }
@@ -519,7 +526,10 @@ class CameraController extends ValueNotifier<CameraValue> {
519526 try {
520527 final XFile file =
521528 await CameraPlatform .instance.stopVideoRecording (_cameraId);
522- value = value.copyWith (isRecordingVideo: false );
529+ value = value.copyWith (
530+ isRecordingVideo: false ,
531+ recordingOrientation: const Optional <DeviceOrientation >.absent (),
532+ );
523533 return file;
524534 } on PlatformException catch (e) {
525535 throw CameraException (e.code, e.message);
@@ -737,7 +747,8 @@ class CameraController extends ValueNotifier<CameraValue> {
737747 await CameraPlatform .instance.lockCaptureOrientation (
738748 _cameraId, orientation ?? value.deviceOrientation);
739749 value = value.copyWith (
740- lockedCaptureOrientation: orientation ?? value.deviceOrientation);
750+ lockedCaptureOrientation: Optional <DeviceOrientation >.of (
751+ orientation ?? value.deviceOrientation));
741752 } on PlatformException catch (e) {
742753 throw CameraException (e.code, e.message);
743754 }
@@ -757,7 +768,8 @@ class CameraController extends ValueNotifier<CameraValue> {
757768 Future <void > unlockCaptureOrientation () async {
758769 try {
759770 await CameraPlatform .instance.unlockCaptureOrientation (_cameraId);
760- value = value.copyWith ();
771+ value = value.copyWith (
772+ lockedCaptureOrientation: const Optional <DeviceOrientation >.absent ());
761773 } on PlatformException catch (e) {
762774 throw CameraException (e.code, e.message);
763775 }
0 commit comments