insert method

void insert(
  1. String insert
)

Implementation

void insert(String insert) {
  final text = editingValue.text;
  final textSelection = editingValue.selection;
  final start = textSelection.start;
  final end = textSelection.end;
  final newText = text.replaceRange(start, end, insert);
  final textLength = insert.length;
  editingValue = editingValue.copyWith(
    text: newText,
    selection: textSelection.copyWith(
      baseOffset: textSelection.start + textLength,
      extentOffset: textSelection.start + textLength,
    ),
    composing: TextRange.empty,
  );

  // Request the attached client to update accordingly.
  widget.embedTextInput.updateEditingValue(editingValue);
}