diff --git a/android/src/main/kotlin/fr/g123k/torch_compat/impl/TorchCamera2Impl.kt b/android/src/main/kotlin/fr/g123k/torch_compat/impl/TorchCamera2Impl.kt index 08feb2d..c4e1ff5 100644 --- a/android/src/main/kotlin/fr/g123k/torch_compat/impl/TorchCamera2Impl.kt +++ b/android/src/main/kotlin/fr/g123k/torch_compat/impl/TorchCamera2Impl.kt @@ -10,9 +10,9 @@ import androidx.annotation.RequiresApi class TorchCamera2Impl(context: Context) : BaseTorch() { private val cameraManager = context.getSystemService(Context.CAMERA_SERVICE) as CameraManager - private val cameraId = cameraManager.cameraIdList.first { cameraId -> + private val cameraId = cameraManager.cameraIdList.firstOrNull { cameraId -> cameraManager.getCameraCharacteristics(cameraId)[CameraCharacteristics.FLASH_INFO_AVAILABLE] != null - } ?: null + } override fun turnOn() { turn(on = true)