setExposureAndFocusPoint method
Use the position
to set exposure and focus.
通过点击点的 position
设置曝光和对焦。
Implementation
Future<void> setExposureAndFocusPoint(
Offset position,
BoxConstraints constraints,
) async {
isFocusPointDisplays.value = false;
if (enableScaledPreview) {
// Ignore point update when the new point is less than 8% and higher than
// 92% of the screen's height.
if (position.dy < constraints.maxHeight / 12 ||
position.dy > constraints.maxHeight / 12 * 11) {
return;
}
}
realDebugPrint(
'Setting new exposure point (x: ${position.dx}, y: ${position.dy})',
);
lastExposurePoint.value = position;
restartExposurePointDisplayTimer();
currentExposureOffset.value = 0;
currentExposureSliderOffset.value = 0;
restartExposureFadeOutTimer();
isFocusPointFadeOut.value = false;
try {
await Future.wait(<Future<void>>[
wrapControllerMethod<void>(
'setExposureOffset',
() => controller.setExposureOffset(0),
),
controller.setExposureOffset(0),
if (controller.value.exposureMode == ExposureMode.locked)
wrapControllerMethod<void>(
'setExposureMode',
() => controller.setExposureMode(ExposureMode.auto),
),
]);
final Offset newPoint = lastExposurePoint.value!.scale(
1 / constraints.maxWidth,
1 / constraints.maxHeight,
);
await Future.wait(<Future<void>>[
if (controller.value.exposurePointSupported)
controller.setExposurePoint(newPoint),
if (controller.value.focusPointSupported)
controller.setFocusPoint(newPoint),
]);
} catch (e, s) {
handleErrorWithHandler(e, s, pickerConfig.onError);
}
}