setFlashMode method

Future<void> setFlashMode(
  1. int mode
)

A setting for whether to fire the flash when capturing photos.

The default value for this setting is CaptureFlashMode.off.

Assuming a static scene, using the CaptureFlashMode.auto setting is equivalent to testing the CapturePhotoOutput.isFlashScene method (which indicates whether flash is recommended for the scene currently visible to the camera), and then setting the flashMode property of your photo settings output accordingly before requesting a capture. However, the visible scene can change between when you request a capture and when the camera hardware captures an image—the automatic setting ensures that the flash is enabled or disabled appropriately at the moment of capture. When the capture occurs, your CapturePhotoCaptureDelegate methods receive an CaptureResolvedPhotoSettings object whose flashEnabled property indicates which flash mode was used for that capture.

Note: When the device becomes very hot, the flash becomes temporarily unavailable until the device cools down (see the CaptureDevice.isFlashAvailable property). While the flash is unavailable, a photo output’s supportedFlashModes method still reports the CaptureFlashMode.on and CaptureFlashMode.auto options as available, so you can still enable the flash in your photo settings even when the flash is temporarily unavailable.

When the photo output calls your CapturePhotoCaptureDelegate methods, check the flashEnabled property of the provided CaptureResolvedPhotoSettings to verify whether the flash is in use.

When specifying a flash mode, the following requirements apply:

  • The specified mode must be present in the photo output’s supportedFlashModes list.

  • You may not enable image stabilization if the flash mode is CaptureFlashMode.on. (Enabling the flash takes priority over the autoStillImageStabilizationEnabled setting).

The capture output validates these requirements when you call the CapturePhotoOutput.capturePhotoWithSettings method. If your settings do not meet these requirements, that method raises an exception.

Implementation

Future<void> setFlashMode(int mode) {
  return _channel.$setFlashMode(this, mode);
}