prevRunePosition method
This method will return the position of the previous rune.
Since the encoding of the String in Dart is UTF-16.
If you want to find the previous character of a position,
you can't just use the position - 1
simply.
This method can help you to compute the position of the previous character.
Implementation
int prevRunePosition(int pos) {
if (pos == 0) {
return pos - 1;
}
final content = toPlainText();
final boundary = CharacterBoundary(content);
final index = boundary.getLeadingTextBoundaryAt(pos - 1);
return index ?? 0;
}