listenEvent static method
void
listenEvent(
- EventTarget target,
- String type, {
- Pointer<
AddEventListenerOptions> ? addEventListenerOptions,
Implementation
static void listenEvent(EventTarget target, String type, {Pointer<AddEventListenerOptions>? addEventListenerOptions}) {
bool isCapture = addEventListenerOptions != null ? addEventListenerOptions.ref.capture : false;
if (!hasListener(target, type, isCapture: isCapture)) {
EventListenerOptions? eventListenerOptions;
if (addEventListenerOptions != null && addEventListenerOptions.ref.capture) {
eventListenerOptions = EventListenerOptions(addEventListenerOptions.ref.capture, addEventListenerOptions.ref.passive, addEventListenerOptions.ref.once);
target.addEventListener(type, _dispatchCaptureEventToNative, addEventListenerOptions: eventListenerOptions);
} else {
target.addEventListener(type, _dispatchNomalEventToNative, addEventListenerOptions: eventListenerOptions);
}
}
if (addEventListenerOptions != null) {
malloc.free(addEventListenerOptions);
}
}