charAt method

String charAt(
  1. int position
)

The character at position. Returns the whole pair for an astral character whose high surrogate sits at position.

Implementation

String charAt(int position) {
  final unit = codeUnitAt(position);
  if (unit < 0) return '';
  if (_U.isHigh(unit)) {
    final next = codeUnitAt(position + 1);
    if (next >= 0 && _U.isLow(next)) {
      return String.fromCharCodes([unit, next]);
    }
  }
  return String.fromCharCode(unit);
}