safeEmitAsFuture method

Future safeEmitAsFuture(
  1. String event, [
  2. Map<String, dynamic>? args
])

Implementation

Future<dynamic> safeEmitAsFuture(
  String event, [
  Map<String, dynamic>? args,
]) async {
  try {
    final Completer<dynamic> completer = Completer<dynamic>();
    Map<String, dynamic> arguments = {
      'callback': completer.complete,
      'errback': completer.completeError,
      ...?args,
    };
    _emitter.emitAsFuture(event, arguments);
    return completer.future;
  } catch (error) {
    logger.e(
      'safeEmitAsFuture() event listener threw an error [event:$event]:$error',
    );
  }
}