applyIf and letIf?

Good point @frozenice - I guess if this can’t be used when the condition depends on the receiver, then it may not be worth adding it to the stdlib then.

Just for more context, I find I need this pattern often with Jetpack Compose, where applying modifiers in a chain happens a lot:

    Component(
        modifier = Modifier
            .horizontalScroll(scrollState)
            .wrapContentSize()
            .letIf(isLargeScreen) {
              it.padding(8.dp)
            }
    )
1 Like