updateCursorPosition method

TextSelection updateCursorPosition(
  1. TextEditingValue oldValue,
  2. String text
)

Implementation

TextSelection updateCursorPosition(
  TextEditingValue oldValue,
  String text,
) {
  var endOffset = max(
    oldValue.text.length - oldValue.selection.end,
    0,
  );

  var selectionEnd = text.length - endOffset;

  return TextSelection.fromPosition(TextPosition(offset: selectionEnd));
}