flush method

void flush()

Flushes any event in buffer.

Implementation

void flush() {
  _eventStream ??= _eventStreamProvider!();

  var es = _eventStream;
  if (es == null) return;

  for (var v in _listenBuffer) {
    es.listen(
      v[0],
      onError: v[1],
      onDone: v[2],
      cancelOnError: v[3],
      singletonIdentifier: v[4],
      singletonIdentifyByInstance: v[5],
      eventValidator: v[6],
      overwriteSingletonSubscription: v[7],
    );
  }

  for (var v in _listenOneShotBuffer) {
    es.listenOneShot(v[0],
        onError: v[1],
        onDone: v[2],
        cancelOnError: v[3],
        singletonIdentifier: v[4],
        singletonIdentifyByInstance: v[5]);
  }

  for (var v in _addBuffer) {
    es.add(v);
  }

  for (var v in _addErrorBuffer) {
    es.addError(v[0], v[1]);
  }

  clearUnflushed();
}