toUint16ArrayPointer method

Pointer<Uint16> toUint16ArrayPointer({
  1. required Allocator allocator,
})

Creates an unsigned short array from this list by copying the list's data, and returns a pointer to it.

nullptr is returned if the list is empty.

Implementation

Pointer<Uint16> toUint16ArrayPointer({required Allocator allocator}) {
  if (isEmpty) {
    return nullptr;
  }
  final Pointer<Uint16> ptr = allocator(sizeOf<Uint16>() * length);
  for (int i = 0; i < length; i++) {
    ptr[i] = this[i];
  }
  return ptr;
}