dispose method

  1. @override
void dispose()
override

Frees all the resources associated with this object.

This marks the object as no longer usable and will make all methods/properties besides mounted inaccessible.

Implementation

@override
void dispose() {
  if (_didDispose) {
    return;
  }
  _didDispose = true;

  _shouldConnect = false;
  _autoReconnectEnabled = false;

  _reconnectTimer?.cancel();
  _reconnectTimer = null;

  _clearConnectAttemptState();

  unawaited(_cancelScanOnly());
  unawaited(_connSub?.cancel());
  unawaited(onConnectionClosed());

  _scanSub = null;
  _connSub = null;

  super.dispose();
}