Use isFlashModeSupported to check whether a flash mode is supported, and then use setFlashMode to set the flash mode.
Refer to the code snippet below.
setFlash(captureSession: camera.PhotoSession,flashMode: camera.FlashMode) {
if (captureSession != null) {
let focusModeStatus: boolean = captureSession?.isFlashModeSupported(flashMode);
if (focusModeStatus) {
captureSession.setFlashMode(flashMode);
}
}
}