String.fromCharCodes constructor

String.fromCharCodes(
  1. Iterable<int> charCodes,
  2. [int start = 0,
  3. int? end]
)

Allocates a new string containing the specified charCodes.

The charCodes can be both UTF-16 code units and runes. If a char-code value is 16-bit, it is used as a code unit:

final string = String.fromCharCodes([68]);
print(string); // D

If a char-code value is greater than 16-bits, it is decomposed into a surrogate pair:

final clef = String.fromCharCodes([0x1D11E]);
clef.codeUnitAt(0); // 0xD834
clef.codeUnitAt(1); // 0xDD1E

If start and end are provided, only the values of charCodes at positions from start to, but not including, end, are used. The start and end values must satisfy 0 <= start <= end. If start is omitted, it defaults to zero, the start of charCodes, and if end is omitted, all char-codes after start are included. If charCodes does not have end, or even start, elements, the specified char-codes may be shorter than end - start, or even empty.

Implementation

external factory String.fromCharCodes(Iterable<int> charCodes,
    [int start = 0, int? end]);