File tree Expand file tree Collapse file tree 4 files changed +35
-10
lines changed Expand file tree Collapse file tree 4 files changed +35
-10
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ that can be found in the LICENSE file. -->
6
6
7
7
## 3.3.1
8
8
9
+ ### New features
10
+
11
+ - Add ` enableScaledPreview ` . (#108 )
12
+
9
13
### Improvements
10
14
11
15
- Prevent unnecessary zoom updates. (#107 )
@@ -32,7 +36,7 @@ that can be found in the LICENSE file. -->
32
36
33
37
### New features
34
38
35
- - Introduce ` onXFileCaptured ` . (#87 )
39
+ - Add ` onXFileCaptured ` . (#87 )
36
40
37
41
## 3.0.4
38
42
Original file line number Diff line number Diff line change @@ -116,7 +116,17 @@ List<PickMethod> get pickMethods {
116
116
),
117
117
),
118
118
PickMethod (
119
- icon: '🔎' ,
119
+ icon: '🔍' ,
120
+ name: 'Prevent scaling for camera preview' ,
121
+ description: 'Camera preview will not be scaled to cover '
122
+ 'the whole screen of the device, only fit with the raw size.' ,
123
+ method: (BuildContext context) => CameraPicker .pickFromCamera (
124
+ context,
125
+ pickerConfig: const CameraPickerConfig (enableScaledPreview: false ),
126
+ ),
127
+ ),
128
+ PickMethod (
129
+ icon: '🌀' ,
120
130
name: 'Lower resolutions' ,
121
131
description: 'Use a lower resolution preset might be helpful '
122
132
'in some specific scenarios.' ,
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ class CameraPickerConfig {
23
23
this .enableExposureControlOnPoint = true ,
24
24
this .enablePinchToZoom = true ,
25
25
this .enablePullToZoomInRecord = true ,
26
+ this .enableScaledPreview = true ,
26
27
this .shouldDeletePreviewFile = false ,
27
28
this .shouldAutoPreviewVideo = false ,
28
29
this .maximumRecordingDuration = const Duration (seconds: 15 ),
@@ -78,6 +79,10 @@ class CameraPickerConfig {
78
79
/// 用户是否可以在录制视频时上拉缩放
79
80
final bool enablePullToZoomInRecord;
80
81
82
+ /// Whether the camera preview should be scaled during captures.
83
+ /// 拍摄过程中相机预览是否需要缩放
84
+ final bool enableScaledPreview;
85
+
81
86
/// {@template wechat_camera_picker.shouldDeletePreviewFile}
82
87
/// Whether the preview file will be delete when pop.
83
88
/// 返回页面时是否删除预览文件
Original file line number Diff line number Diff line change @@ -1327,15 +1327,21 @@ class CameraPickerState extends State<CameraPicker>
1327
1327
controller,
1328
1328
preview,
1329
1329
);
1330
- preview = transformedWidget ?? preview;
1331
-
1332
- preview = RotatedBox (
1333
- quarterTurns: - config.cameraQuarterTurns,
1334
- child: Transform .scale (
1330
+ preview = Center (child: transformedWidget ?? preview);
1331
+ // Scale the preview if the config is enabled.
1332
+ if (config.enableScaledPreview) {
1333
+ preview = Transform .scale (
1335
1334
scale: _effectiveCameraScale (constraints, controller),
1336
- child: Center (child: preview),
1337
- ),
1338
- );
1335
+ child: preview,
1336
+ );
1337
+ }
1338
+ // Rotated the preview if the turns is valid.
1339
+ if (config.cameraQuarterTurns % 4 != 0 ) {
1340
+ preview = RotatedBox (
1341
+ quarterTurns: - config.cameraQuarterTurns,
1342
+ child: preview,
1343
+ );
1344
+ }
1339
1345
return preview;
1340
1346
}
1341
1347
You can’t perform that action at this time.
0 commit comments