toOwnedBytes method

Uint8List toOwnedBytes()

Returns a byte buffer that is safe to retain.

  • If isBorrowed is true, this returns a copy.
  • If isBorrowed is false and contiguous, this returns the owned bytes.

Implementation

Uint8List toOwnedBytes() {
  _ensureValid();
  if (!isBorrowed && _off1 == 0 && _len1 == _buf1.length && _len2 == 0) {
    return _buf1;
  }
  return toBytes();
}