public object Saver : ComposeSaver<TextFieldState, Any>
Saves and restores a TextFieldState for rememberSaveable.
A restored state has no onTextChanged callback. To restore a state that was created with onTextChanged, use the Saver returned by TextFieldState.Saver(onTextChanged).
Functions
save
override fun SaverScope.save(value: TextFieldState): Any?
restore
override fun restore(value: Any): TextFieldState?
invoke
public operator fun invoke(
onTextChanged: ((CharSequence) -> Unit)?
): ComposeSaver<TextFieldState, Any>
Returns a Saver that saves a TextFieldState the same way as Saver and passes onTextChanged to the restored state.
A lambda cannot be saved, so a state restored by Saver has no onTextChanged. Use this function to save a state that was created with onTextChanged, for example with rememberSaveable(saver = TextFieldState.Saver(onTextChanged)). rememberTextFieldState does this.
onTextChanged is called after each commit that changes the text of the restored state: user input, TextFieldState.edit and its helpers, and undo/redo. It is not called when only the selection, composition, or styles change. onTextChanged runs on the thread that made the edit, before the edit call returns. When onTextChanged runs, TextFieldState.text and TextFieldState.selection show the new value, the undo entry is recorded, and the IME has been notified.
onTextChanged must not change the state. Calling TextFieldState.edit, its helpers, or UndoState.undo and UndoState.redo on the state from onTextChanged throws an IllegalStateException. To intercept and modify user input, use InputTransformation.
The CharSequence passed to onTextChanged is provided for convenience and has the same text content as TextFieldState.text.
Parameters
| onTextChanged | Called after each commit that changes the text of the restored state, receiving the new text with the same content as TextFieldState.text. |