ifFalse

inline fun Modifier.ifFalse(predicate: Boolean, builder: Modifier.() -> Modifier): Modifier

Modifier to make it easy to conditionally add a modifier based on predicate

Box(
modifier = Modifier.fillMaxWidth()
.ifFalse(isError) { background(SparkTheme.colors.valid) }
.padding(16.dp)
) {...}

Parameters

predicate

condition to decide if the builder is added or not to the modifier chain

builder

the modifier(s) to apply when predicate is false