How to set an icon's color to [default color] in jetpack compose?

Viewed 690

An icon has a default color, and it could be different under different themes.

When meet the condition, I hope the icon's color become Color.RED, otherwise it used the default color (example, white on one theme and yellow on another theme)

But I don't know the grammar of how to set to default color. Please help, thanks a lot!

val judge = ... //a mutableStateOf Boolean
...
// how to set [default color]?
Icon(painterResource(R.drawable.ic_baseline_error_outline_24), 
    contentDescription = null, 
    tint = if (judge) Color.RED else [default color])
1 Answers

If you go to Icon file you see its value:

tint: Color = LocalContentColor.current.copy(alpha = LocalContentAlpha.current)

You can just set it again

Related