apply method Null safety

  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 asyncronous
  // nature of the connection between the framework and platform text input plugins.
  String newText = oldText;
  assert(_debugTextRangeIsValid(replacedRange, newText), 'Applying TextEditingDeltaReplacement failed, the replacedRange: $replacedRange is not within the bounds of $newText of length: ${newText.length}');
  newText = _replace(newText, replacementText, replacedRange);
  assert(_debugTextRangeIsValid(selection, newText), 'Applying TextEditingDeltaReplacement failed, the selection range: $selection is not within the bounds of $newText of length: ${newText.length}');
  assert(_debugTextRangeIsValid(composing, newText), 'Applying TextEditingDeltaReplacement 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);
}