Coil Kotlin Uri to Bitmap throws null pointer exception
Trying to convert a Uri image file to Bitmap in Kotlin fails with a Null Pointer exception. How can I fix this?
var bitmap = remember { mutableStateOf(null)}
LaunchedEffect(key1 = "tobitmap") {
CoroutineScope(
Dispatchers.IO).launch {
bitmap.value = uriToBitmap(
context,
shoppingListScreenViewModel.state.value.imageUri
)
}
}
Image(
bitmap = bitmap.value?.asImageBitmap()!!, //Throws exception here
contentDescription = ""
)
private...