apply method

  1. @override
TextEditingValue apply(
  1. TextEditingValue value
)
override

This method will take the given TextEditingValue and return a new TextEditingValue with that instance of TextEditingDelta applied to it.

Implementation

@override
TextEditingValue apply(TextEditingValue value) {
  // To stay inline with the plain text model we should follow a last write wins
  // policy and apply the delta to the oldText. This is due to the asynchronous
  // nature of the connection between the framework and platform text input plugins.
  String newText = oldText;
  assert(_debugTextRangeIsValid(TextRange.collapsed(insertionOffset), newText), 'Applying TextEditingDeltaInsertion failed, the insertionOffset: $insertionOffset is not within the bounds of $newText of length: ${newText.length}');
  newText = _replace(newText, textInserted, TextRange.collapsed(insertionOffset));
  assert(_debugTextRangeIsValid(selection, newText), 'Applying TextEditingDeltaInsertion failed, the selection range: $selection is not within the bounds of $newText of length: ${newText.length}');
  assert(_debugTextRangeIsValid(composing, newText), 'Applying TextEditingDeltaInsertion failed, the composing range: $composing is not within the bounds of $newText of length: ${newText.length}');
  return value.copyWith(text: newText, selection: selection, composing: composing);
}