setExposureAndFocusPoint method

Future<void> setExposureAndFocusPoint(
  1. TapUpDetails details,
  2. BoxConstraints constraints
)

Use the details point to set exposure and focus.

Implementation

Future<void> setExposureAndFocusPoint(
  TapUpDetails details,
  BoxConstraints constraints,
) async {
  _isExposureModeDisplays.value = false;
  // Ignore point update when the new point is less than 8% and higher than
  // 92% of the screen's height.
  if (details.globalPosition.dy < constraints.maxHeight / 12 ||
      details.globalPosition.dy > constraints.maxHeight / 12 * 11) {
    return;
  }
  realDebugPrint(
    'Setting new exposure point ('
    'x: ${details.globalPosition.dx}, '
    'y: ${details.globalPosition.dy}'
    ')',
  );
  _lastExposurePoint.value = Offset(
    details.globalPosition.dx,
    details.globalPosition.dy,
  );
  _restartPointDisplayTimer();
  _currentExposureOffset.value = 0;
  await controller.setExposureOffset(0);
  if (_exposureMode.value == ExposureMode.locked) {
    await controller.setExposureMode(ExposureMode.auto);
    _exposureMode.value = ExposureMode.auto;
  }
  unawaited(controller.setExposurePoint(
    _lastExposurePoint.value!.scale(
      1 / constraints.maxWidth,
      1 / constraints.maxHeight,
    ),
  ));
  if (controller.value.focusPointSupported == true) {
    unawaited(controller.setFocusPoint(
      _lastExposurePoint.value!.scale(
        1 / constraints.maxWidth,
        1 / constraints.maxHeight,
      ),
    ));
  }
}