resize method Null safety

void resize(
  1. int byteCount
)

Implementation

void resize(int byteCount) {
  if (isValid) malloc.free(pointer!);

  pointer = malloc.allocate<Uint8>(byteCount);

  if (pointer!.address == nullptr.address) throw Exception("NativeDataStruct.resize: Failed to allocate a $byteCount bytes");

  bytes = pointer!.asTypedList(byteCount);
}