logout method

void logout()

logout the user if logged in

Implementation

void logout() {
  // Completer c = Completer();
  // TODO: use future instead of relying on [init] input
  if (_loginState != LoginState.connected) {
    return;
  }
  Random random = Random();
  int id = random.nextInt(9999);
  final listener = EventListener(
    '$id',
    (dynamic data) {
      _loginState = LoginState.disconnected;
      _userInfo = null;
      // c.complete();
    },
    once: true,
  );
  _eventEmitter.addEventListener(listener);

  _injectJavaScript('{type: "$METHOD_LOGOUT",id:"$id"}');

  // TODO: To be removed when fix is done on auth wallet page
  _loginState = LoginState.disconnected;
  _userInfo = null;
  // return c.future;
}