Hello! I'm trying to add background image for card...
# compose
a
Hello! I'm trying to add background image for card in a list and card has a favourite toggle. When favourite state changing the composable function re-drawing the card and background re-drawing again. Is it possible to avoid re-drawing background image every time?
l
how are you drawing the image?
a
I tried to use DrawImage
Copy code
loadImageResource(imageResId).resource.resource?.let {
    DrawImage(image = it)
}
or
Copy code
DrawImage(imageResource(imageResId))
a
to add draw caches you need to wrap Image into RepaintBoundary. this basically first draws Image into RenderNode and then reuses this rendernode
a
Thank you for your answer, it was my fault I used ModelList with immutable data and created copy of object when pressed favourite button