safeEmitAsFuture method

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

Implementation

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