shutdown method

Future<void> shutdown()

Implementation

Future<void> shutdown() async {
  if (_shutdown) return;
  _shutdown = true;

  try {
    await _subscription?.cancel();
  } catch (_) {
    // Subscription may already be closed or in error state.
  }
  _subscription = null;

  try {
    await _controller?.close();
  } catch (_) {
    // Controller may already be closed.
  }
  _controller = null;
}