Skip to content

Instantly share code, notes, and snippets.

@KatieBarnett
Last active September 27, 2023 10:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KatieBarnett/b32e80f5d2a9ebce0f6f948aeb4f26d6 to your computer and use it in GitHub Desktop.
Save KatieBarnett/b32e80f5d2a9ebce0f6f948aeb4f26d6 to your computer and use it in GitHub Desktop.
Inline conditional modifier
inline fun Modifier.conditional(
condition: Boolean,
ifTrue: Modifier.() -> Modifier,
ifFalse: Modifier.() -> Modifier = { this },
): Modifier = if (condition) {
then(ifTrue(Modifier))
} else {
then(ifFalse(Modifier))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment