logout static method

dynamic logout({
  1. dynamic onSuccess(
    1. String
    )?,
  2. dynamic onError(
    1. CometChatException excep
    )?,
})

used to logout user

method could throw PlatformException with error codes specifying the cause

Implementation

static logout(
    {dynamic Function(String)? onSuccess,
    Function(CometChatException excep)? onError}) async {
  if (!checkAuthSettings(onError)) return;
  await CometChat.logout(
    onSuccess: (message) {
      CometChatUIKit.loggedInUser = null;
      if (onSuccess != null) {
        try {
          onSuccess(message);
        } catch (e) {
          if (kDebugMode) {
            debugPrint(
                'user logout was successful: $message, but unable to execute custom onSuccess callback');
          }
        }
      }
    },
    onError: (error) {
      if (onError != null) {
        try {
          onError(error);
        } catch (e) {
          if (kDebugMode) {
            debugPrint(
                'user logout was unsuccessful: ${error.message}, but unable to execute custom onError callback');
          }
        }
      }
    },
  );
  ChatConfigurator.init();
}