setTextState method
void
setTextState({})
Replaces the current text and selection state.
Implementation
void setTextState({
required String text,
required int selectionBase,
required int selectionExtent,
bool recordHistory = true,
}) {
_runEditFrame(() {
_beginHistoryAction(_TextInputHistoryAction.setText, breakChain: true);
if (recordHistory) {
_recordUndoSnapshot();
}
final graphemes = textPrepareInsertedGraphemes(
uni.codePoints(text),
multiline: multiline,
);
final err = _validate(graphemes);
_setValueInternal(graphemes, err);
final base = selectionBase.clamp(0, _value.length);
final extent = selectionExtent.clamp(0, _value.length);
_applyOffsetStateSnapshot(
TextOffsetStateSnapshot.selection(
baseOffset: base,
extentOffset: extent,
cursorOffset: extent,
),
);
_resetDesiredCol();
_handleOverflow();
_updateSuggestions();
});
}