ursus
01/02/2023, 10:27 PMImage
to be never skipped?
Image(
modifier = Modifier
.size(48.dp)
.padding(12.dp),
painter = painterResource(id = R.drawable.ic_headphones),
contentDescription = null,
)
I’m looking around in Layout monitor and I see this never skipped when ui is recomposedmattinger
01/02/2023, 11:37 PMEko Prasetyo
01/03/2023, 4:38 AMrememberPainterResource()
instead of painterResource()
?mattinger
01/03/2023, 5:06 AMEko Prasetyo
01/03/2023, 5:14 AMZach Klippenstein (he/him) [MOD]
01/03/2023, 12:14 PMpainterResource
, if it’s a bitmap, I’m guessing this might be because it remembers the bitmap but creates a new BitmapPainter
every time, which implements equals
but isn’t marked as @Stable
and contains a non-stable ImageBitmap
field so probably isn’t inferred as stable either.ursus
01/03/2023, 12:15 PMZach Klippenstein (he/him) [MOD]
01/03/2023, 12:25 PMursus
01/03/2023, 12:25 PMZach Klippenstein (he/him) [MOD]
01/03/2023, 12:35 PMZach Klippenstein (he/him) [MOD]
01/03/2023, 12:35 PMkenkyee
01/03/2023, 12:45 PMAlbert Chang
01/03/2023, 2:31 PMPainter
is not a stable class, it seems expected that Image
is not skippable.ursus
01/03/2023, 2:33 PMAlbert Chang
01/03/2023, 2:42 PMPainter
are guaranteed to be stable.ursus
01/03/2023, 2:44 PMAlbert Chang
01/03/2023, 2:54 PMursus
01/03/2023, 2:56 PMkenkyee
01/03/2023, 2:58 PMZach Klippenstein (he/him) [MOD]
01/03/2023, 2:58 PMZach Klippenstein (he/him) [MOD]
01/03/2023, 3:20 PMursus
01/03/2023, 4:56 PM@Composable
fun Image(
painter: Painter,
contentDescription: String?,
modifier: Modifier = Modifier, <------
alignment: Alignment = Alignment.Center, <------
contentScale: ContentScale = ContentScale.Fit, <------
alpha: Float = DefaultAlpha, <------
colorFilter: ColorFilter? = null <------
) {
Zach Klippenstein (he/him) [MOD]
01/03/2023, 6:15 PM