setZoom method

  1. @override
Future<void> setZoom(
  1. double value
)
override

Set a zoom value for a device.

This must be >= minZoom and <= maxZoom.

This value is a multiplier. For example, a value of 2.0 doubles the size of an image’s subject (and halves the field of view). Allowed values typically range from 1.0 (full field of view) to the value of maxZoom. Setting the value of this property jumps immediately to the new zoom factor. For a smooth transition, use the smoothZoomTo.

zoomSupported should be called before this.

Implementation

@override
Future<void> setZoom(double value) async {
  verifyInitialized();
  verifyNotDisposed();
  final List<int> zoomRatios = await cameraParameters.getZoomRatios();

  final int valueZoomRatio = (value * 100).round();
  assert(valueZoomRatio >= 100);
  assert(valueZoomRatio < (zoomRatios.last + 1));

  final int index = lowerBound<int>(zoomRatios, (value * 100).round());
  cameraParameters.setZoom(index);
  return camera.setParameters(cameraParameters);
}