waitTillEventIsReceived method

  1. @visibleForTesting
Future<void> waitTillEventIsReceived(
  1. Type event, {
  2. int? count,
  3. Duration timeout = const Duration(seconds: 1),
})

Waits till given event is received by this instance

event - event type to check count - optional count of events that must have been received timeout - maximum duration to wait for events

Implementation

@visibleForTesting
Future<void> waitTillEventIsReceived(
  Type event, {
  int? count,
  Duration timeout = const Duration(seconds: 1),
}) async {
  await for (final _ in _testReceivedEventsController.stream
      .timeout(timeout, onTimeout: (s) => s.close())) {
    if (checkEventWasReceived(event, count: count)) {
      break;
    }
  }
}