setFlashMode method

  1. @override
Future<void> setFlashMode(
  1. FlashMode mode
)
override

Set the flash mode when taking images.

Users should call supportedFlashModes before calling this method. Not all FlashModes are supported on all devices. Some won't support any.

This should only be called after passing as a parameter to a CameraController and CameraController.initialize has been called.

Implementation

@override
Future<void> setFlashMode(FlashMode mode) {
  verifyAttached();
  switch (mode) {
    case FlashMode.on:
      _controller.cameraParameters.setFlashMode(CameraParameters.flashModeOn);
      break;
    case FlashMode.off:
      _controller.cameraParameters.setFlashMode(
        CameraParameters.flashModeOff,
      );
      break;
    case FlashMode.auto:
      _controller.cameraParameters.setFlashMode(
        CameraParameters.flashModeAuto,
      );
      break;
  }
  return _controller.camera.setParameters(_controller.cameraParameters);
}