text property

String get text

The complete text content of the editor.

Getting this property returns the full document text. Setting this property replaces all content and moves the cursor to the end.

Implementation

String get text {
  if (_cachedText == null || _cachedTextVersion != _currentVersion) {
    if (_bufferLineIndex != null && _bufferDirty) {
      final ropeText = _rope.getText();
      final before = ropeText.substring(0, _bufferLineRopeStart);
      final after = ropeText.substring(
        _bufferLineRopeStart + _bufferLineOriginalLength,
      );
      _cachedText = before + _bufferLineText! + after;
    } else {
      _cachedText = _rope.getText();
    }
    _cachedTextVersion = _currentVersion;
  }
  return _cachedText!;
}
set text (String newText)

Implementation

set text(String newText) {
  _rope = Rope(newText);
  _currentVersion++;
  _selection = TextSelection.collapsed(offset: newText.length);
  dirtyRegion = TextRange(start: 0, end: newText.length);
  notifyListeners();
}