readFully method

void readFully(
  1. List bytes, {
  2. int? len,
  3. int? off,
  4. Endian endian = Endian.big,
})

Implementation

void readFully(List bytes, {int? len, int? off, Endian endian = Endian.big}) {
  if (len != null || off != null) {
    if ((len != null && off == null) || (len == null && off != null))
      throw ArgumentError("You must supply both [len] and [off] values.");
    if (len! < 0 || off! < 0)
      throw RangeError("$off - $len is out of bounds");
    if (len == 0) return;
  }

  if (len != null) {
    bytes.addAll(data.getRange(off!, len));
  } else {
    fillList(bytes, readBytes(bytes.length));
  }
}