How to reload an image after a failed load in Jetpack Compose? #816
-
val painter = rememberImagePainter(url)
Image(
modifier = Modifier.fillMaxSize(),
painter = painter,
contentDescription = null,
contentScale = ContentScale.Fit
)
when (val state = painter.state) {
is ImagePainter.State.Error -> {
TextButton(onClick = { }) { Text("retry") }
}
}After a failed load, the user should be able to reload the image via the retry button. |
Beta Was this translation helpful? Give feedback.
Answered by
colinrtwhite
Jul 23, 2021
Replies: 1 comment 1 reply
-
|
It does seem like we need an API for this. As a work-around, you can do something like |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
FishHawk
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It does seem like we need an API for this. As a work-around, you can do something like
painter.request = painter.request.newBuilder().setParameter("", Unit, null).build()to restart the request.