Skip to content

Commit ff0f6d3

Browse files
leftcodingAlexV525
andauthored
CameraPickerConfig.preferredFlashMode (#158)
Co-authored-by: Alex Li <[email protected]>
1 parent edaeac8 commit ff0f6d3

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ that can be found in the LICENSE file. -->
66

77
## 3.7.0
88

9+
### New features
10+
11+
- Add `preferredFlashMode`, allowing users to choose which flash mode is preferred when first using the camera. (#158)
12+
913
### Improvements
1014

1115
- Allow flash modes failed to switch and can move on to next when switching. (#156)

lib/src/constants/config.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class CameraPickerConfig {
3333
this.resolutionPreset = ResolutionPreset.max,
3434
this.imageFormatGroup = ImageFormatGroup.unknown,
3535
this.preferredLensDirection = CameraLensDirection.back,
36+
this.preferredFlashMode = FlashMode.auto,
3637
this.lockCaptureOrientation,
3738
this.foregroundBuilder,
3839
this.previewTransformBuilder,
@@ -138,6 +139,11 @@ class CameraPickerConfig {
138139
/// 摄像机在拍摄时锁定的旋转角度
139140
final DeviceOrientation? lockCaptureOrientation;
140141

142+
/// Which flash mode is preferred when first using the camera,
143+
/// typically with the auto mode.
144+
/// 首次使用相机时首选的闪光灯,通常是自动模式。
145+
final FlashMode preferredFlashMode;
146+
141147
/// {@macro wechat_camera_picker.EntitySaveCallback}
142148
final EntitySaveCallback? onEntitySaving;
143149

lib/src/states/camera_picker_state.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ class CameraPickerState extends State<CameraPicker>
337337
newController
338338
.getMinZoomLevel()
339339
.then((double value) => minAvailableZoom = value),
340+
if (pickerConfig.preferredFlashMode != FlashMode.auto)
341+
newController.setFlashMode(pickerConfig.preferredFlashMode),
340342
],
341343
eagerError: true,
342344
);

0 commit comments

Comments
 (0)