Kshitij Patil
02/18/2021, 11:23 AMModifier.padding()
.preferredSize()
.apply {
if(<some condition>) {
this.then(Modifier.clickable { })
}
}
but didn’t workDenis
02/18/2021, 11:26 AMapply
returns this
, maybe try run
?
https://kotlinlang.org/docs/scope-functions.html#function-selectiongrandstaish
02/18/2021, 11:27 AMModifier.padding()
.preferredSize()
.then(if (x) Modifier.clickable(...) else Modifier)
Kshitij Patil
02/18/2021, 11:34 AMgrandstaish
02/18/2021, 11:40 AMval click = if (x) {
Modifier.clickable(...)
} else {
Modifier
}
Modifier.padding()
.preferredSize()
.then(click)
You see this pattern throughout foundational codeAlbert Chang
02/18/2021, 11:53 AMrun
if you want to avoid unnecessary wrapping of the modifier.Kshitij Patil
02/18/2021, 12:21 PM