rememberTextFieldState

Functions summary

TextFieldState
@Composable
rememberTextFieldState(initialText: String, initialSelection: TextRange)

Create and remember a TextFieldState.

Cmn

Functions

rememberTextFieldState

@Composable
fun rememberTextFieldState(
    initialText: String = "",
    initialSelection: TextRange = TextRange(initialText.length)
): TextFieldState

Create and remember a TextFieldState. The state is remembered using rememberSaveable and so will be saved and restored with the composition.

If you need to store a TextFieldState in another object, use the TextFieldState.Saver object to manually save and restore the state.

Parameters
initialText: String = ""

The initial text state. If a different value is passed in a subsequent recomposition, the value of the state will not be updated. To update the state after it's initialized, call methods on TextFieldState.

initialSelection: TextRange = TextRange(initialText.length)

The initial selection state. If a different value is passed in a subsequent recomposition, the value of the state will not be updated. To update the state after it's initialized, call methods on TextFieldState.