setVideoStabilizationMode method
Future<void>
setVideoStabilizationMode(
- VideoStabilizationMode mode, {
- bool allowFallback = true,
Set the video stabilization mode for the selected camera.
When allowFallback is true (default) the camera will be set to the best
video stabilization mode up to, and including, mode.
When allowFallback is false and if mode is not one of the supported
modes (see getSupportedVideoStabilizationModes), then it throws an
ArgumentError.
This feature is only available if getSupportedVideoStabilizationModes returns at least one value other than VideoStabilizationMode.off.
Implementation
Future<void> setVideoStabilizationMode(
VideoStabilizationMode mode, {
bool allowFallback = true,
}) async {
_throwIfNotInitialized('setVideoStabilizationMode');
try {
final VideoStabilizationMode? modeToSet =
await _getVideoStabilizationModeToSet(mode, allowFallback);
// When _getVideoStabilizationModeToSet returns null
// it means that the device doesn't support any
// video stabilization mode and that doing nothing
// is valid because allowFallback is true or [mode]
// is [VideoStabilizationMode.off], so this results
// in a no-op.
if (modeToSet == null) {
return;
}
await CameraPlatform.instance.setVideoStabilizationMode(
_cameraId,
modeToSet,
);
value = value.copyWith(videoStabilizationMode: modeToSet);
} on PlatformException catch (e) {
throw CameraException(e.code, e.message);
}
}