flush method

Future<void> flush()

Flushes all remaining events through the sink and shuts down the queue.

Re-entrant calls await the same in-flight flush, so a caller that awaits flush while another flush is already running does not resolve before NavigationAnalyticsSink.flush has completed. This matters for NavigationController.dispose, which awaits flush before calling super.dispose() — without this guard a concurrent flush could let disposal proceed while the sink is still flushing.

Implementation

Future<void> flush() {
  if (_isShutdown) return _flushInFlight ?? Future<void>.value();

  _isShutdown = true;
  final future = _performFlush();
  _flushInFlight = future;
  return future;
}