getLoggedInUser static method
Future<User?>
getLoggedInUser({
- dynamic onSuccess()?,
- dynamic onError(
- CometChatException excep
Returns logged in User Object
check of getLoggedInUser() function in your app where you check App's user login status. In case it returns nil then you need to call the Login method inside it.
Implementation
static Future<User?> getLoggedInUser({Function(User)? onSuccess, Function(CometChatException excep)? onError}) async {
try {
final result = await channel.invokeMethod('getLoggedInUser');
if (result == null) return null;
final User res = User.fromMap(result);
if(onSuccess != null) onSuccess(res);
return res;
} on PlatformException catch (platformException) {
if(onError != null) onError(CometChatException(platformException.code, platformException.details, platformException.message));
return null;
} catch (e) {
debugPrint("Error: $e");
if(onError != null) onError(CometChatException(ErrorCode.errorUnhandledException, e.toString() , e.toString()));
return null;
}
}