Composable Function

rememberTextFieldState

Create and remember a TextFieldState.

RememberTextFieldStateOnTextChangedSample

@Sampled
@Composable
fun RememberTextFieldStateOnTextChangedSample(onNameChanged: (String) -> Unit) {
    // The composable owns the state. onNameChanged is read again on every recomposition, so the
    // latest lambda is always the one that runs.
    val state = rememberTextFieldState(onTextChanged = { onNameChanged(it.toString()) })
    BasicTextField(state)
}
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: