callListener method

Future<void> callListener(
  1. Map<String, dynamic> action
)

Implementation

Future<void> callListener(Map<String, dynamic> action) {
  var completer = Completer<void>();

  channel
      .push(event: "run", payload: action)
      ?.receive("ok", (response) => completer.complete())
      .receive(
        "error",
        (response) => completer
            .completeError("An error occurred while calling the listener"),
      );

  return completer.future;
}