subset method Null safety

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

Implementation

List<int> subset(int start, [int? end]) {
  if (_bufferPosition > 0) {
    flush();
  }

  final pos = _fp.positionSync();
  if (start < 0) {
    start = pos + start;
  }
  var length = 0;
  if (end == null) {
    end = pos;
  } else if (end < 0) {
    end = pos + end;
  }
  length = (end - start);
  _fp.setPositionSync(start);
  final buffer = Uint8List(length);
  _fp.readIntoSync(buffer);
  _fp.setPositionSync(pos);
  return buffer;
}