setExposureAndFocusPoint method

Future<void> setExposureAndFocusPoint(
  1. Offset position,
  2. BoxConstraints constraints
)

Use the position to set exposure and focus. 通过点击点的 position 设置曝光和对焦。

Implementation

Future<void> setExposureAndFocusPoint(
  Offset position,
  BoxConstraints constraints,
) async {
  isFocusPointDisplays.value = false;
  // 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;
  try {
    if (controller.value.exposureMode == ExposureMode.locked) {
      await controller.setExposureMode(ExposureMode.auto);
    }
    final Offset newPoint = lastExposurePoint.value!.scale(
      1 / constraints.maxWidth,
      1 / constraints.maxHeight,
    );
    if (controller.value.exposurePointSupported) {
      controller.setExposurePoint(newPoint);
    }
    if (controller.value.focusPointSupported) {
      controller.setFocusPoint(newPoint);
    }
  } catch (e, s) {
    handleErrorWithHandler(e, pickerConfig.onError, s: s);
  }
}