getRange method

Iterable<int> getRange([
  1. int offset = 0,
  2. int? length
])

Reads a region of the buffer.

Items are read from the range [offset : offset+length]. If length is omitted, the range extends to the end of the buffer.

The range must satisy the relations 0offsetoffset+lengththis.length.

final Buffer buffer = Buffer.fromList([1, 2, 3, 4, 5, 6, 7, 8]);
print(buffer.getRange());     // [1, 2, 3, 4, 5, 6, 7, 8]
print(buffer.getRange(2));    // [3, 4, 5, 6, 7, 8]
print(buffer.getRange(2, 4)); // [3, 4, 5, 6]

Implementation

Iterable<int> getRange([final int offset = 0, final int? length]) {
  final int rngLength = length ?? this.length - offset;
  return _data.getRange(offset, rngLength);
}