subset method Null safety

  1. @override
InputStreamBase subset(
  1. [int? position,
  2. int? length]
)
override

Return a InputStream to read a subset of this stream. It does not move the read position of this stream. position is specified relative to the start of the buffer. If position is not specified, the current read position is used. If length is not specified, the remainder of this stream is used.

Implementation

@override
InputStreamBase subset([int? position, int? length]) {
  if (position == null) {
    position = offset;
  } else {
    position += start;
  }

  if (length == null || length < 0) {
    length = _length - (position - start);
  }

  return InputStream(buffer,
      byteOrder: byteOrder, start: position, length: length);
}