encodeUint16List method

Uint8List encodeUint16List()

Encodes this List to a Uint8List of Uint16.

Implementation

Uint8List encodeUint16List() {
  final length = this.length;

  final bs = Uint8List(length * 2);
  final byteData = bs.asByteData();
  var byteDataOffset = 0;

  for (var i = 0; i < length; ++i) {
    var n = this[i];
    byteData.setUint16(byteDataOffset, n);
    byteDataOffset += 2;
  }

  return bs;
}