convert method

Uint8List convert(
  1. String string,
  2. [int start = 0,
  3. int? end]
)
inherited

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.

Implementation

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