updateExposureOffset method

Future<void> updateExposureOffset(
  1. double value
)

Update the exposure offset using the exposure controller. 使用曝光控制器更新曝光值

Implementation

Future<void> updateExposureOffset(double value) async {
  // Normalize the new exposure value if exposures have steps.
  if (exposureStep > 0) {
    final double inv = 1.0 / exposureStep;
    double roundedOffset = (value * inv).roundToDouble() / inv;
    if (roundedOffset > maxAvailableExposureOffset) {
      roundedOffset = (value * inv).floorToDouble() / inv;
    } else if (roundedOffset < minAvailableExposureOffset) {
      roundedOffset = (value * inv).ceilToDouble() / inv;
    }
    value = roundedOffset;
  }
  if (value == currentExposureOffset.value ||
      value < minAvailableExposureOffset ||
      value > maxAvailableExposureOffset) {
    return;
  }
  currentExposureOffset.value = value;
  try {
    // Use [CameraPlatform] explicitly to reduce channel calls.
    await CameraPlatform.instance.setExposureOffset(
      controller.cameraId,
      value,
    );
  } catch (e, s) {
    handleErrorWithHandler(e, pickerConfig.onError, s: s);
  }
  if (!isFocusPointDisplays.value) {
    isFocusPointDisplays.value = true;
  }
  restartDisplayModeDisplayTimer();
  restartExposurePointDisplayTimer();
}