disconnect method Null safety

Future<void> disconnect()
inherited

Implementation

Future<void> disconnect() async {
  if (_isConnected) {
    log('disconnecting', initial: initialApp);
    isLoggedIn = false;
    _isConnected = false;
    isSocketClosingExpected = true;
    try {
      await _socketStreamSubscription.cancel();
    } catch (e) {
      print('unable to cancel subscription $e');
    }
    try {
      await _socket.close();
    } catch (e) {
      print('unable to close socket $e');
    }
  }
}