thenIf

inline fun Modifier.thenIf(condition: Boolean, onFalse: Modifier.() -> Modifier = { this }, onTrue: Modifier.() -> Modifier = { this }): Modifier

Applies onTrue or onFalse depending on condition.

Inside onTrue, condition is known to be true; inside onFalse, it is known to be false.

Example:

Modifier.thenIf(
condition = isSelected,
onTrue = { background(Color.Green) },
onFalse = { background(Color.Gray) }
)

inline fun Modifier.thenIf(condition: Boolean, onTrue: Modifier.() -> Modifier): Modifier

Applies onTrue when condition is true.

Inside onTrue, condition is known to be true.

Example:

Modifier.thenIf(isSelected) {
background(Color.Green)
}