Function

then

Merge this style with another style where this style will be applied before the other style.

BasicTextFieldInputTransformationChainingSample

@Sampled
fun BasicTextFieldInputTransformationChainingSample() {
    val removeFirstEFilter = InputTransformation {
        val index = asCharSequence().indexOf('e')
        if (index != -1) {
            replace(index, index + 1, "")
        }
    }
    val printECountFilter = InputTransformation {
        println("found ${asCharSequence().count { it == 'e' }} 'e's in the string")
    }

    // Returns a filter that always prints 0 e's.
    removeFirstEFilter.then(printECountFilter)

    // Returns a filter that prints the number of e's before the first one is removed.
    printECountFilter.then(removeFirstEFilter)
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: