setText method

void setText(
  1. String v, {
  2. bool recordHistory = true,
})

Replaces the text and collapses the cursor at the end.

Implementation

void setText(String v, {bool recordHistory = true}) {
  _runEditFrame(() {
    _beginHistoryAction(_TextAreaHistoryAction.setText, breakChain: true);
    if (recordHistory) {
      _recordUndoSnapshot();
    }
    final limited = _applyCharLimit(v);
    _replaceText(limited);
    _collapseLineState(
      TextPosition(
        line: lineCount - 1,
        column: _document.lineLength(lineCount - 1),
      ),
    );
    _lastDocumentChange = null;
  });
}