Vrihas Pathak
01/10/2023, 10:25 AMthen()
" and "returning a modifier directly" while creating a custom modifier?sindrenm
01/10/2023, 10:41 AMmyModifier.foo()
myModifier then Modifier.foo()
Where then
shines is if you conditionally apply modifiers, for instance:
val otherModifier = if (expression) {
Modifier.foo()
} else {
Modifier.bar()
}
val fullModifier = myModifier then otherModifier
Loney Chou
01/10/2023, 4:14 PMfun Modifier.foo(): Modifier = object : Modifier.Element {}
fun Modifier.bar(): Modifier = this then object : Modifier.Element {}
By calling modifier.foo()
will it remove all the modifiers that modifier
has and remain that anonymous object, while by calling modifier.bar()
will it create a CombinedModifier
which retain other modifiers.mattinger
01/11/2023, 4:51 AMthis
when creating a modifier through an extension function like above. You could in theory turn off that off for lint, but it's there for a reason.