String.fromCharCodes constructor Null safety

  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 <= charCodes.length.


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