Skip to content

Instantly share code, notes, and snippets.

@mori-atsushi
Created February 6, 2022 22:57
Show Gist options
  • Save mori-atsushi/d8cd9c1e10561ef408228b015298a295 to your computer and use it in GitHub Desktop.
Save mori-atsushi/d8cd9c1e10561ef408228b015298a295 to your computer and use it in GitHub Desktop.
package com.github.moriatsushi.compose
import androidx.compose.ui.Modifier
inline fun <T : Any> Modifier.ifNotNull(value: T?, builder: (T) -> Modifier): Modifier {
return then(if (value != null) builder(value) else Modifier)
}
inline fun Modifier.ifTrue(value: Boolean, builder: () -> Modifier): Modifier {
return then(if (value) builder() else Modifier)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment