eventListener static method

String eventListener({
  1. String selector = "document",
  2. required String event,
  3. List<String> args = const [],
  4. required String body,
})

Build a javascript event listener.

selector is the selector of the element to listen to. Defaults to document. event is the javascript event to listen to. args are the parameters accepted by the closure. body is the code that will be executed when the event is triggered.

Implementation

static String eventListener({
  String selector = "document",
  required String event,
  List<String> args = const [],
  required String body,
}) =>
    "$selector.addEventListener('$event', ${callbackClosure(args: args, body: body)});";