List<int> convert(String string, [int start = 0, int end])

Converts the String into a list of its code units.

If start and end are provided, only the substring string.substring(start, end) is used as input to the conversion.

Source

List<int> convert(String string, [int start = 0, int end]) {
  int stringLength = string.length;
  RangeError.checkValidRange(start, end, stringLength);
  if (end == null) end = stringLength;
  int length = end - start;
  List result = new Uint8List(length);
  for (int i = 0; i < length; i++) {
    var codeUnit = string.codeUnitAt(start + i);
    if ((codeUnit & ~_subsetMask) != 0) {
      throw new ArgumentError("String contains invalid characters.");
    }
    result[i] = codeUnit;
  }
  return result;
}