updatePreset method

  1. @override
Future<void> updatePreset(
  1. CameraControllerPreset preset
)
override

Called when a CameraController has changed CameraControllerPresets.

Implementation

@override
Future<void> updatePreset(CameraControllerPreset preset) async {
  verifyAttached();
  final List<CameraSize> supportedSizes =
      await _controller.cameraParameters.getSupportedPictureSizes();

  _sortCameraSizes(supportedSizes);
  switch (preset) {
    case CameraControllerPreset.low:
      _controller.cameraParameters.setPictureSize(
        supportedSizes.first.width,
        supportedSizes.first.height,
      );
      break;
    case CameraControllerPreset.medium:
      final int midIndex = ((supportedSizes.length - 1) / 2).round();
      _controller.cameraParameters.setPictureSize(
        supportedSizes[midIndex].width,
        supportedSizes[midIndex].height,
      );
      break;
    case CameraControllerPreset.high:
      _controller.cameraParameters.setPictureSize(
        supportedSizes.last.width,
        supportedSizes.last.height,
      );
      break;
  }

  return _controller.camera.setParameters(_controller.cameraParameters);
}