anchorAtCharIndex method
Returns a new SelectionAnchor at the provided character index.
Implementation
SelectionAnchor? anchorAtCharIndex(
int i, {
bool trim = true,
}) {
assert(rp != null);
var offset = math.min(trimmedSel.end - 1, math.max(trimmedSel.start, i));
// If trimming whitespace, skip whitespace.
if (trim) {
while (offset < trimmedSel.end && _shouldSkip(text.codeUnitAt(offset))) {
offset++;
}
if (offset == trimmedSel.end) return null;
}
final range = rp!.getWordBoundary(TextPosition(offset: offset));
return anchorAtRange(range, trim: trim);
}