getOffsetBefore method

int? getOffsetBefore(
  1. int offset
)

Returns the closest offset before offset at which the input cursor can be positioned.

Implementation

int? getOffsetBefore(int offset) {
  final int? prevCodeUnit = _text!.codeUnitAt(offset - 1);
  if (prevCodeUnit == null) {
    return null;
  }
  return isLowSurrogate(prevCodeUnit) ? offset - 2 : offset - 1;
}