subset method Null safety

List<int> subset(
  1. int start,
  2. [int? end]
)

Return the subset of the buffer in the range start:end.

If start or end are < 0 then it is relative to the end of the buffer. If end is not specified (or null), then it is the end of the buffer. This is equivalent to the python list range operator.

Implementation

List<int> subset(int start, [int? end]) {
  if (start < 0) {
    start = (length) + start;
  }

  if (end == null) {
    end = length;
  } else if (end < 0) {
    end = length + end;
  }

  return Uint8List.view(_buffer.buffer, start, end - start);
}