toRaw method

Pointer<NativeType> toRaw([
  1. int extraLength = 0
])

Implementation

Pointer toRaw([int extraLength = 0]) {
  Pointer<RawNativeEvent> event = malloc.allocate<RawNativeEvent>(sizeOf<RawNativeEvent>());

  EventTarget? _target = target;
  EventTarget? _currentTarget = currentTarget;

  List<int> methods = [
    stringToNativeString(type).address,
    bubbles ? 1 : 0,
    cancelable ? 1 : 0,
    timeStamp,
    defaultPrevented ? 1 : 0,
    (_target != null && _target.pointer != null) ? _target.pointer!.address : nullptr.address,
    (_currentTarget != null && _currentTarget.pointer != null) ? _currentTarget.pointer!.address : nullptr.address,
  ];

  int totalLength = methods.length + extraLength;

  final Pointer<Uint64> bytes = malloc.allocate<Uint64>(totalLength * sizeOf<Uint64>());
  bytes.asTypedList(methods.length).setAll(0, methods);
  event.ref.bytes = bytes;
  event.ref.length = methods.length;

  return event.cast<Pointer>();
}