convertToUint16List method

Uint16List convertToUint16List(
  1. int length, [
  2. Endian endian = Endian.big
])

Copies this ByteData buffer to an Uint16List of length.

Implementation

Uint16List convertToUint16List(int length, [Endian endian = Endian.big]) {
  _checkLengthRange(length, 2);

  if (Endian.host == endian) {
    return Uint16List.fromList(buffer.asUint16List(offsetInBytes, length));
  }

  var ns = Uint16List(length);

  for (var i = 0; i < length; ++i) {
    ns[i] = getUint16(i * 2, endian);
  }

  return ns;
}