@@ -49,6 +49,7 @@ class CameraPicker extends StatefulWidget {
49
49
this .resolutionPreset = ResolutionPreset .max,
50
50
this .imageFormatGroup = ImageFormatGroup .unknown,
51
51
this .preferredLensDirection = CameraLensDirection .back,
52
+ this .lockCaptureOrientation,
52
53
this .cameraQuarterTurns = 0 ,
53
54
this .foregroundBuilder,
54
55
this .onEntitySaving,
@@ -75,6 +76,11 @@ class CameraPicker extends StatefulWidget {
75
76
}
76
77
}
77
78
79
+ /// Whether the camera should be locked to the specific orientation
80
+ /// during captures.
81
+ /// 摄像机在拍摄时锁定的旋转角度
82
+ final DeviceOrientation ? lockCaptureOrientation;
83
+
78
84
/// The number of clockwise quarter turns the camera view should be rotated.
79
85
/// 摄像机视图顺时针旋转次数,每次90度
80
86
final int cameraQuarterTurns;
@@ -181,6 +187,7 @@ class CameraPicker extends StatefulWidget {
181
187
ResolutionPreset resolutionPreset = ResolutionPreset .max,
182
188
ImageFormatGroup imageFormatGroup = ImageFormatGroup .unknown,
183
189
CameraLensDirection preferredLensDirection = CameraLensDirection .back,
190
+ DeviceOrientation ? lockCaptureOrientation,
184
191
Widget Function (CameraValue )? foregroundBuilder,
185
192
EntitySaveCallback ? onEntitySaving,
186
193
CameraErrorHandler ? onError,
@@ -212,6 +219,7 @@ class CameraPicker extends StatefulWidget {
212
219
resolutionPreset: resolutionPreset,
213
220
imageFormatGroup: imageFormatGroup,
214
221
preferredLensDirection: preferredLensDirection,
222
+ lockCaptureOrientation: lockCaptureOrientation,
215
223
foregroundBuilder: foregroundBuilder,
216
224
onEntitySaving: onEntitySaving,
217
225
onError: onError,
@@ -571,10 +579,13 @@ class CameraPickerState extends State<CameraPicker>
571
579
572
580
try {
573
581
await controller.initialize ();
582
+ // Call recording preparation first.
574
583
if (shouldPrepareForVideoRecording) {
575
584
await controller.prepareForVideoRecording ();
576
585
}
586
+ // Then call other asynchronous methods.
577
587
Future .wait (< Future <void >> [
588
+ controller.lockCaptureOrientation (widget.lockCaptureOrientation),
578
589
(() async => _maxAvailableExposureOffset =
579
590
await controller.getMaxExposureOffset ())(),
580
591
(() async => _minAvailableExposureOffset =
0 commit comments