addTextAfterCursor method

void addTextAfterCursor(
  1. String text
)

在光标后插入文本

Implementation

void addTextAfterCursor(String text) {
  String value = this.text;
  int start = selection.start;
  int end = selection.end;
  String newValue = value.substring(0, start) + text + value.substring(end);
  int newSelection = start + text.length;
  this.value = this.value.copyWith(
      text: newValue,
      selection: TextSelection.collapsed(offset: newSelection));
}