toUtf16 method

int toUtf16(
  1. int codePointIndex
)

Convert a codepoint index (from TextRun.textIndexAt) to a UTF-16 code unit index. Returns the index unchanged when all characters are BMP.

Implementation

int toUtf16(int codePointIndex) {
  if (_cpToUtf16 == null) return codePointIndex;
  return codePointIndex < _cpToUtf16.length
      ? _cpToUtf16[codePointIndex]
      : indices.length - 1;
}