https://kotlinlang.org logo
Title
s

Stylianos Gakis

03/24/2023, 9:34 AM
Is there a way to get a Drawable from a ImageVector? I want to use something like
androidx.compose.material.icons.Icons.Default.ArrowForward
as a placeholder for my Coil AsyncImage, but it only takes in a
@DrawableRes
or a
Drawable
. Looking for if I am missing some way to do ImageVector -> Drawable before I opt to use the SubComposeAsyncImage instead.
a

Albert Chang

03/24/2023, 9:45 AM
Why not use the placeholder parameter of AsyncImage? It takes a
Painter
so you can use
rememberVectorPainter(imageVector)
.
s

Stylianos Gakis

03/24/2023, 9:53 AM
Narrator: Turns out, he was in fact missing something obvious. Yep that should actually do the trick. Thanks a lot! I was fixated looking at the options I get in my
ImageRequest.Builder
and used the wrong AsyncImage import, so I didn’t see this version 🤦‍♂️.