replaceRange function
Implementation
TextEditResult replaceRange(
List<String> graphemes, {
required int start,
required int end,
List<String> replacement = const <String>[],
int? cursorOffset,
}) {
final normalizedStart = start.clamp(0, graphemes.length);
final normalizedEnd = end.clamp(normalizedStart, graphemes.length);
final next = List<String>.from(graphemes, growable: true)
..replaceRange(normalizedStart, normalizedEnd, replacement);
return TextEditResult(
graphemes: next,
cursorOffset: (cursorOffset ?? (normalizedStart + replacement.length))
.clamp(0, next.length),
);
}