@@ -9,6 +9,7 @@ import 'package:camera_platform_interface/camera_platform_interface.dart';
9
9
import 'package:flutter/foundation.dart' ;
10
10
import 'package:flutter/material.dart' ;
11
11
import 'package:flutter/services.dart' ;
12
+ import 'package:quiver/core.dart' ;
12
13
13
14
import '../camera.dart' ;
14
15
@@ -160,10 +161,10 @@ class CameraValue {
160
161
bool ? exposurePointSupported,
161
162
bool ? focusPointSupported,
162
163
DeviceOrientation ? deviceOrientation,
163
- DeviceOrientation ? lockedCaptureOrientation,
164
- DeviceOrientation ? recordingOrientation,
164
+ Optional < DeviceOrientation > ? lockedCaptureOrientation,
165
+ Optional < DeviceOrientation > ? recordingOrientation,
165
166
bool ? isPreviewPaused,
166
- DeviceOrientation ? previewPauseOrientation,
167
+ Optional < DeviceOrientation > ? previewPauseOrientation,
167
168
}) {
168
169
return CameraValue (
169
170
isInitialized: isInitialized ?? this .isInitialized,
@@ -180,12 +181,16 @@ class CameraValue {
180
181
exposurePointSupported ?? this .exposurePointSupported,
181
182
focusPointSupported: focusPointSupported ?? this .focusPointSupported,
182
183
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,
186
190
isPreviewPaused: isPreviewPaused ?? this .isPreviewPaused,
187
- previewPauseOrientation:
188
- previewPauseOrientation ?? this .previewPauseOrientation,
191
+ previewPauseOrientation: previewPauseOrientation == null
192
+ ? this .previewPauseOrientation
193
+ : previewPauseOrientation.orNull,
189
194
);
190
195
}
191
196
@@ -353,8 +358,8 @@ class CameraController extends ValueNotifier<CameraValue> {
353
358
await CameraPlatform .instance.pausePreview (_cameraId);
354
359
value = value.copyWith (
355
360
isPreviewPaused: true ,
356
- previewPauseOrientation:
357
- value.lockedCaptureOrientation ?? value.deviceOrientation);
361
+ previewPauseOrientation: Optional < DeviceOrientation >. of (
362
+ value.lockedCaptureOrientation ?? value.deviceOrientation)) ;
358
363
} on PlatformException catch (e) {
359
364
throw CameraException (e.code, e.message);
360
365
}
@@ -367,7 +372,9 @@ class CameraController extends ValueNotifier<CameraValue> {
367
372
}
368
373
try {
369
374
await CameraPlatform .instance.resumePreview (_cameraId);
370
- value = value.copyWith (isPreviewPaused: false );
375
+ value = value.copyWith (
376
+ isPreviewPaused: false ,
377
+ previewPauseOrientation: const Optional <DeviceOrientation >.absent ());
371
378
} on PlatformException catch (e) {
372
379
throw CameraException (e.code, e.message);
373
380
}
@@ -498,8 +505,8 @@ class CameraController extends ValueNotifier<CameraValue> {
498
505
value = value.copyWith (
499
506
isRecordingVideo: true ,
500
507
isRecordingPaused: false ,
501
- recordingOrientation:
502
- value.lockedCaptureOrientation ?? value.deviceOrientation);
508
+ recordingOrientation: Optional < DeviceOrientation >. of (
509
+ value.lockedCaptureOrientation ?? value.deviceOrientation)) ;
503
510
} on PlatformException catch (e) {
504
511
throw CameraException (e.code, e.message);
505
512
}
@@ -519,7 +526,10 @@ class CameraController extends ValueNotifier<CameraValue> {
519
526
try {
520
527
final XFile file =
521
528
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
+ );
523
533
return file;
524
534
} on PlatformException catch (e) {
525
535
throw CameraException (e.code, e.message);
@@ -737,7 +747,8 @@ class CameraController extends ValueNotifier<CameraValue> {
737
747
await CameraPlatform .instance.lockCaptureOrientation (
738
748
_cameraId, orientation ?? value.deviceOrientation);
739
749
value = value.copyWith (
740
- lockedCaptureOrientation: orientation ?? value.deviceOrientation);
750
+ lockedCaptureOrientation: Optional <DeviceOrientation >.of (
751
+ orientation ?? value.deviceOrientation));
741
752
} on PlatformException catch (e) {
742
753
throw CameraException (e.code, e.message);
743
754
}
@@ -757,7 +768,8 @@ class CameraController extends ValueNotifier<CameraValue> {
757
768
Future <void > unlockCaptureOrientation () async {
758
769
try {
759
770
await CameraPlatform .instance.unlockCaptureOrientation (_cameraId);
760
- value = value.copyWith ();
771
+ value = value.copyWith (
772
+ lockedCaptureOrientation: const Optional <DeviceOrientation >.absent ());
761
773
} on PlatformException catch (e) {
762
774
throw CameraException (e.code, e.message);
763
775
}
0 commit comments