ifNull

inline fun <T : Any> Modifier.ifNull(value: T?, builder: Modifier.() -> Modifier): Modifier

Modifier to make it easy to conditionally add a modifier based on value nullability

Box(
modifier = Modifier.fillMaxWidth()
.ifNull(errorMetadata) { errorData -> background(errorData.valid) }
.padding(16.dp)
) {...}

Parameters

value

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

builder

the modifier(s) to apply when value is null