Skip to content

Commit fc645bc

Browse files
committed
🚀 Set focus point and exposure point at the same time if supported
1 parent c161b0c commit fc645bc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/src/widget/camera_picker.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ class CameraPickerState extends State<CameraPicker>
573573

574574
/// Use the [details] point to set exposure and focus.
575575
/// 通过点击点的 [details] 设置曝光和对焦。
576-
void setExposurePoint(TapUpDetails details) {
576+
void setExposureAndFocusPoint(TapUpDetails details) {
577577
assert(controller != null);
578578
// Ignore point update when the new point is less than 8% and higher than
579579
// 92% of the screen's height.
@@ -596,6 +596,11 @@ class CameraPickerState extends State<CameraPicker>
596596
controller.setExposurePoint(
597597
_lastExposurePoint.value.scale(1 / Screens.width, 1 / Screens.height),
598598
);
599+
if (controller.value?.focusPointSupported == true) {
600+
controller.setFocusPoint(
601+
_lastExposurePoint.value.scale(1 / Screens.width, 1 / Screens.height),
602+
);
603+
}
599604
if (_exposureMode.value == ExposureMode.locked) {
600605
_exposureMode.value = ExposureMode.auto;
601606
}
@@ -1081,7 +1086,7 @@ class CameraPickerState extends State<CameraPicker>
10811086
Widget _exposureDetectorWidget(BuildContext context) {
10821087
return Positioned.fill(
10831088
child: GestureDetector(
1084-
onTapUp: setExposurePoint,
1089+
onTapUp: setExposureAndFocusPoint,
10851090
behavior: HitTestBehavior.translucent,
10861091
child: const SizedBox.expand(),
10871092
),

0 commit comments

Comments
 (0)