@Composable
fun loadIcon(
applicationInfo: ApplicationInfo?,
): State<ImageBitmap?> {
val context = LocalContext.current
return produceState(initialValue = null, applicationInfo) {
withContext(Dispatchers.Default) {
value = applicationInfo?.loadIcon(context.packageManager)?.toBitmap()?.asImageBitmap()
}
}
}
No more compiles with error
Copy code
Type mismatch: inferred type is ImageBitmap? but Nothing? was expected
Tolriq
06/02/2021, 6:35 PM
I also switched to Kotlin 1.5.10
d
Dominaezzz
06/02/2021, 6:42 PM
produceState<ImageBitmap>(
. Looks like a bug though.
t
Tolriq
06/02/2021, 6:44 PM
From changelog state variance is now out so maybe there's some expected things to modify, but I must admit that I do not fully master those variance things.
But yes forcing the type works thanks.