setControllerPreset method
Set a preset configuration for a CameraController.
To guarantee that a CameraOutput returns a value from CameraOutput.outputSize, a user should await the future returned by this method.
Implementation
@override
Future<void> setControllerPreset(CameraControllerPreset preset) async {
verifyInitialized();
verifyNotDisposed();
final List<String> supportedPresets =
await session.canSetSessionPresets(<String>[
CaptureSessionPreset.preset352x288,
CaptureSessionPreset.preset640x480,
CaptureSessionPreset.iFrame960x540,
CaptureSessionPreset.preset1280x720,
CaptureSessionPreset.preset1920x1080,
]);
switch (preset) {
case CameraControllerPreset.low:
capturePreset = supportedPresets.first;
return session.setSessionPreset(supportedPresets.first);
case CameraControllerPreset.medium:
final int midIndex = ((supportedPresets.length - 1) / 2).round();
capturePreset = supportedPresets[midIndex];
return session.setSessionPreset(supportedPresets[midIndex]);
case CameraControllerPreset.high:
capturePreset = supportedPresets.last;
return session.setSessionPreset(supportedPresets.last);
}
}