getFocusDistances method

Future<List<double>> getFocusDistances()

Gets the distances from the camera to where an object appears to be in focus.

The object is sharpest at the optimal focus distance. The depth of field is the far focus distance minus near focus distance.

Focus distances may change after calling Camera.autoFocus, Camera.cancelAutoFocus, or Camera.startPreview. Applications can call Camera.getParameters and this method anytime to get the latest focus distances. If the focus mode is focusModeContinuousVideo, focus distances may change from time to time.

This method is intended to estimate the distance between the camera and the subject. After auto-focus, the subject distance may be within near and far focus distance. However, the precision depends on the camera hardware, auto-focus algorithm, the focus area, and the scene. The error can be large and it should be only used as a reference.

Far focus distance >= optimal focus distance >= near focus distance. If the focus distance is infinity, the value will be Float.POSITIVE_INFINITY (Java).

Implementation

Future<List<double>> getFocusDistances() async {
  final List<Object?> distances =
      await _channel.$getFocusDistances(this) as List<Object?>;
  return distances.cast<double>();
}