nextRunePosition method

int nextRunePosition(
  1. int pos
)

This method will return the position of the next rune.

Since the encoding of the String in Dart is UTF-16. If you want to find the next character of a position, you can't just use the position + 1 simply.

This method can help you to compute the position of the next character.

Implementation

int nextRunePosition(int pos) {
  final content = toPlainText();
  if (pos >= content.length - 1) {
    return content.length;
  }
  final boundary = CharacterBoundary(content);
  final index = boundary.getTrailingTextBoundaryAt(pos);
  return index ?? content.length;
}