exportAsBytes method

List<int> exportAsBytes(
  1. int startElement,
  2. int nrElements

Returns a copy of the internal bytes data starting at startElement and containing nrElements elements.

Care must be taken that startElement + nrElements <= length. Note that this is not a view, because a view would allow the caller to modify the contents directly, thereby bypassing any checks related to sorted state.


List<int> exportAsBytes(int startElement, int nrElements) {
  final startByte = _elementNrToByteOffset(startElement);
  final endByte = _elementNrToByteOffset(nrElements);
  final view = _rawData.buffer.asUint8List(startByte, endByte);

  // Convert the view to a new list, so the internal buffer data cannot be
  // modified by the recipient of the result, which would allow bypassing
  // internal checks regarding sorted state.
  return view.toList(growable: false);