dispose method

Future<void> dispose()

Stops the server and closes its streams permanently. Safe to call twice.

Implementation

Future<void> dispose() {
  if (_disposeFuture != null) return _disposeFuture!;
  _disposing = true;
  return _disposeFuture = _operations.then((_) async {
    try {
      await _cleanup();
    } finally {
      _transition(BleServerState.disposed);
      // Broadcast stream close futures can be held by paused consumers.
      unawaited(_states.close());
      unawaited(_events.close());
      unawaited(_errors.close());
    }
  });
}