convert method Null safety

String convert(
  1. List<int> bytes,
  2. [int start = 0,
  3. int? end]
)
inherited

Converts the bytes (a list of unsigned 7- or 8-bit integers) to the corresponding string.

If start and end are provided, only the sub-list of bytes from start to end (end not inclusive) is used as input to the conversion.

Implementation

String convert(List<int> bytes, [int start = 0, int? end]) {
  end = RangeError.checkValidRange(start, end, bytes.length);
  for (var i = start; i < end; i++) {
    var byte = bytes[i];
    if ((byte & ~_subsetMask) != 0) {
      if (!_allowInvalid) {
        throw FormatException("Invalid value in input: $byte");
      }
      return _convertInvalid(bytes, start, end);
    }
  }
  return String.fromCharCodes(bytes, start, end);
}