dispose method

void dispose()

Synchronous teardown. The observer and client reference are cleared immediately so any in-flight lifecycle/onTokenRefresh callback that races against shutdown short-circuits at the _client == null guard. The stream subscription is cancelled in the background — its future is intentionally not awaited because callers of RelevaClient.dispose are synchronous.

Implementation

void dispose() {
  if (!_initialized) return;
  _initialized = false;
  WidgetsBinding.instance.removeObserver(this);
  _client = null;
  final sub = _tokenRefreshSub;
  _tokenRefreshSub = null;
  // ignore: discarded_futures
  sub?.cancel();
}