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

myanmarking

01/26/2022, 7:28 PM
I don’t understand why the image is not loading with coil. Can some1 spot the mistake? It’s a valid url
Copy code
if (imageUrl == null) {
    placeHolderComposable()
} else {
    val load: ImagePainter = rememberImagePainter(
        data = imageUrl
    )

    when (val state = load.state) {
        ImagePainter.State.Empty,
        is ImagePainter.State.Loading,
        is ImagePainter.State.Error -> {
            placeHolderComposable()
        }
        is ImagePainter.State.Success -> {
            Image(
                modifier = Modifier
                    .size(imageSize)
                    .then(imagePaddingModifier),
                painter = state.painter,
                contentDescription = imageContentDescription
            )
        }
    }
}
The state never advances from empty. why
a

Aditya Murthy

01/26/2022, 9:16 PM
I don't think you need the 'is' for every condition. Try removing it
m

myanmarking

01/26/2022, 11:24 PM
nah that’s not it. for some reason, this does not work
my guess is that the request won’t start unless it’s attached to something. Cannot do it like this
54 Views