https://kotlinlang.org logo
#compose
Title
# compose
b

bodo

07/27/2021, 12:39 PM
Is it possible to load network images in the compose preview?
n

Nathan Castlehow

07/27/2021, 12:41 PM
I’m thinking no. I wasn’t able to get it to load so instead had it show a placeholder image in preview mode.
Copy code
if (LocalInspectionMode.current || state !is ImagePainter.State.Empty ) {
    placeholder()
}
b

bodo

07/27/2021, 12:51 PM
that is sad, but thanks for the little workaround for placeholders in preview mode
n

Nathan Castlehow

07/27/2021, 1:06 PM
I should say that I remember it working when you deploy the preview to device. I just had issues when using Preview in android studio (which is where its most useful for me).
c

cb

07/27/2021, 2:28 PM
The preview in Android Studio doesn't (generally) have access to the network, so no way to load images.
3 Views