useEventListener<E extends Event> function
void
useEventListener<E extends Event>(
- String type,
- void listener(
- E event
- WebEventTargetResolver? target,
- bool enabled = true,
- WebEventListenerOptions options = const WebEventListenerOptions(),
Subscribes to a native DOM event after the first browser frame.
Omitting target listens on the browser window. A supplied resolver that
returns null leaves the hook detached until a later build resolves a target.
Implementation
void useEventListener<E extends web.Event>(
String type,
void Function(E event) listener, {
WebEventTargetResolver? target,
bool enabled = true,
WebEventListenerOptions options = const WebEventListenerOptions(),
}) {
if (type.isEmpty) throw ArgumentError.value(type, 'type', 'must not be empty');
use(_EventListenerHook<E>(type, listener, target, enabled, options));
}