toUint8List method

Uint8List? toUint8List(
  1. int length
)

Creates a Uint8List from this pointer by copying the pointer's data.

length is the length of the array.

null is returned if the pointer is equal to nullptr.

Implementation

Uint8List? toUint8List(int length) {
  if (this == nullptr) {
    return null;
  }
  final Uint8List list = Uint8List(length);
  for (int i = 0; i < length; i++) {
    list[i] = this[i];
  }
  return list;
}