Chris Fillmore
06/07/2022, 3:28 PMChris Fillmore
06/07/2022, 3:28 PME java.lang.IllegalStateException: Reading a state that was created after the snapshot was taken or in a snapshot that has not yet been applied
E at androidx.compose.runtime.snapshots.SnapshotKt.readError(Snapshot.kt:1791)
E at androidx.compose.runtime.snapshots.SnapshotKt.readable(Snapshot.kt:1786)
E at androidx.compose.runtime.snapshots.SnapshotKt.readable(Snapshot.kt:1777)
E at androidx.compose.runtime.SnapshotMutableStateImpl.getValue(SnapshotState.kt:130)
E at com.example.android.camera.LiveLiterals$CameraCharacteristicsExtKt.Boolean$arg-1$call-EQEQ$fun-$get-hasFlashUnit$$get$val-hasFlashUnit(Unk
nown Source:27)
E at com.example.android.camera.CameraCharacteristicsExtKt.getHasFlashUnit(CameraCharacteristicsExt.kt:68)
(stack trace edited to remove my package name)Chris Fillmore
06/07/2022, 3:29 PMval CameraCharacteristics.hasFlashUnit: Boolean get() {
return get(CameraCharacteristics.FLASH_INFO_AVAILABLE) == true
}
Chris Fillmore
06/07/2022, 3:29 PM@Composable
fun CameraScreen(
...
currentCameraCharacteristics: CameraCharacteristics,
) {
if (currentCameraCharacteristics.hasFlashUnit) {
// show an icon to enable the torch
}
}
Chris Fillmore
06/07/2022, 3:29 PMval currentCameraCharacteristics by cameraOwner.currentCameraCharacteristics.collectAsState()
CameraScreen(
...,
currentCameraCharacteristics = currentCameraCharacteristics,
)
Chris Fillmore
06/07/2022, 3:31 PMChris Fillmore
06/07/2022, 3:33 PMChris Fillmore
06/07/2022, 3:34 PMLiveLiterals$CameraCharacteristicsExtKt.Boolean$arg-1$call-EQEQ$fun-$get-hasFlashUnit$$get$val-hasFlashUnit(Unk
nown Source:27)
Chris Fillmore
06/07/2022, 3:34 PMChris Fillmore
06/07/2022, 3:34 PMColton Idle
06/07/2022, 3:57 PMChris Fillmore
06/07/2022, 3:57 PMColton Idle
06/07/2022, 3:57 PMChris Fillmore
06/07/2022, 3:59 PMColton Idle
06/07/2022, 4:01 PMColton Idle
06/07/2022, 4:02 PM