updatePreset method
Called when a CameraController has changed CameraControllerPresets.
Implementation
@override
Future<void> updatePreset(CameraControllerPreset preset) async {
verifyAttached();
final List<CameraSize> supportedSizes =
await _controller.cameraParameters.getSupportedPreviewSizes();
_sortCameraSizes(supportedSizes);
switch (preset) {
case CameraControllerPreset.low:
_controller.cameraParameters.setPreviewSize(
supportedSizes.first.width,
supportedSizes.first.height,
);
break;
case CameraControllerPreset.medium:
final int midIndex = ((supportedSizes.length - 1) / 2).round();
_controller.cameraParameters.setPreviewSize(
supportedSizes[midIndex].width,
supportedSizes[midIndex].height,
);
break;
case CameraControllerPreset.high:
_controller.cameraParameters.setPreviewSize(
supportedSizes.last.width,
supportedSizes.last.height,
);
break;
}
return _controller.camera.setParameters(_controller.cameraParameters);
}