getLoggedInUser static method
getLoggedInUser checks if any session is active and retrieves the User data of the logged in user
Implementation
static Future<User?> getLoggedInUser(
{dynamic Function(User)? onSuccess,
dynamic Function(CometChatException)? onError}) async {
User? user = await CometChat.getLoggedInUser(onSuccess: (user) {
CometChatUIKit.loggedInUser = user;
//executing the custom onSuccess handler
if (onSuccess != null) {
try {
onSuccess(user);
} catch (e) {
if (kDebugMode) {
debugPrint("failed to execute onSuccess callback");
}
}
}
}, onError: (error) {
//executing the custom onError handler
if (onError != null) {
try {
onError(error);
} catch (e) {
if (kDebugMode) {
debugPrint("failed to execute onError callback");
}
}
}
});
return user;
}