@@ -34,6 +34,7 @@ class CameraPicker extends StatefulWidget {
34
34
this .maximumRecordingDuration = const Duration (seconds: 15 ),
35
35
this .theme,
36
36
this .resolutionPreset = ResolutionPreset .max,
37
+ this .quarterTurns = 0 ,
37
38
CameraPickerTextDelegate textDelegate,
38
39
}) : assert (
39
40
isAllowRecording == true || isOnlyAllowRecording != true ,
@@ -50,6 +51,10 @@ class CameraPicker extends StatefulWidget {
50
51
: DefaultCameraPickerTextDelegate ());
51
52
}
52
53
54
+ /// Quarter rotate turns.
55
+ /// 摄像机视图旋转次数
56
+ final int quarterTurns;
57
+
53
58
/// Whether the picker can record video.
54
59
/// 选择器是否可以录像
55
60
final bool isAllowRecording;
@@ -81,6 +86,7 @@ class CameraPicker extends StatefulWidget {
81
86
bool isOnlyAllowRecording = false ,
82
87
Duration maximumRecordingDuration = const Duration (seconds: 15 ),
83
88
ThemeData theme,
89
+ int cameraQuarterTurns = 0 ,
84
90
CameraPickerTextDelegate textDelegate,
85
91
ResolutionPreset resolutionPreset = ResolutionPreset .max,
86
92
}) async {
@@ -99,6 +105,7 @@ class CameraPicker extends StatefulWidget {
99
105
isAllowRecording: isAllowRecording,
100
106
isOnlyAllowRecording: isOnlyAllowRecording,
101
107
theme: theme,
108
+ quarterTurns: cameraQuarterTurns,
102
109
textDelegate: textDelegate,
103
110
resolutionPreset: resolutionPreset,
104
111
),
@@ -533,8 +540,7 @@ class CameraPickerState extends State<CameraPicker> {
533
540
children: < Widget > [
534
541
const Spacer (),
535
542
// TODO(Alex): There's an issue tracking NPE of the camera plugin, so switching is temporary disabled .
536
- if ((cameras? .length ?? 0 ) > 1 )
537
- switchCamerasButton,
543
+ if ((cameras? .length ?? 0 ) > 1 ) switchCamerasButton,
538
544
],
539
545
),
540
546
);
@@ -683,9 +689,12 @@ class CameraPickerState extends State<CameraPicker> {
683
689
children: < Widget > [
684
690
if (isInitialized)
685
691
Center (
686
- child: AspectRatio (
687
- aspectRatio: cameraController.value.aspectRatio,
688
- child: CameraPreview (cameraController),
692
+ child: RotatedBox (
693
+ quarterTurns: widget.quarterTurns ?? 0 ,
694
+ child: AspectRatio (
695
+ aspectRatio: cameraController.value.aspectRatio,
696
+ child: CameraPreview (cameraController),
697
+ ),
689
698
),
690
699
)
691
700
else
0 commit comments