BasicText now has a `ColorProducer` parameter; I t...
# compose
z
BasicText now has a
ColorProducer
parameter; I think I get the gist of it, but are there any usage examples out there for a curious mind?
b
It's a way to move the color change out of composition so it doesn't cause recomposition when changing. Its as simple as
Copy code
val color by animateColorAsState(if (enabled) Color.Green else Color.Red)

BasicText(text = "Hello", color = { color })
🙌 1
z
Thanks Ben! 💪🏽
s
ColorProducer
is basically
() -> Color
which doesn't box the color value
🙌 1
a
Hi, I notice that this is available only for
BasicText
and not for
Text
. Is there a specific reason for this, or will it be made available later?”
113 Views