Adding a error image inside ImageRequest builder #2801
-
val imageRequest = remember(asset.id, showImageDownloadFailedWarning) {
ImageRequest.Builder(context)
.data(asset.link)
.error(Res.drawable.ic_image_slash_small)
.build()
} adding a drawable inside error no longer works for compose multiplatform coil version, what's the new way of doing this? |
Beta Was this translation helpful? Give feedback.
Answered by
colinrtwhite
Jan 29, 2025
Replies: 1 comment
-
If you're using a standard Android resource there's an extension function that you can import to make your code snippit work. Alternatively you can pass it as a painter. This also works for Compose Multiplatform resources: AsyncImage(
model = imageRequest,
error = painterResource(Res.drawable.ic_image_slash_small),
contentDescription = null,
) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ismai117
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you're using a standard Android resource there's an extension function that you can import to make your code snippit work.
Alternatively you can pass it as a painter. This also works for Compose Multiplatform resources: