codeUnitAt method

int codeUnitAt (int index)

Returns the UTF-16 code unit at the given index in the flattened string.

Returns null if the index is out of bounds.

Implementation

int codeUnitAt(int index) {
  if (index < 0)
    return null;
  int offset = 0;
  int result;
  visitTextSpan((TextSpan span) {
    if (index - offset < span.text.length) {
      result = span.text.codeUnitAt(index - offset);
      return false;
    }
    offset += span.text.length;
    return true;
  });
  return result;
}