getLoggedInUser static method

Future<User?> getLoggedInUser({
  1. dynamic onSuccess(
    1. User
    )?,
  2. dynamic onError(
    1. 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 (p) {
    _errorCallbackHandler(null, p, null, onError);
    return null;
  } catch (e) {
    _errorCallbackHandler(null, null, e, onError);
    return null;
  }
}