getFromUser method

Future<NIMUserInfo?> getFromUser()

Implementation

Future<NIMUserInfo?> getFromUser() async {
  if (applicantAccountId == null) {
    return null;
  } else {
    var accountId = applicantAccountId;
    if (applicantAccountId == getIt<IMLoginService>().userInfo?.accountId) {
      accountId = operatorAccountId;
    }

    if (accountId != null) {
      var userResult =
          await NimCore.instance.userService.getUserList([accountId]);
      if (userResult.isSuccess &&
          userResult.data != null &&
          userResult.data!.isNotEmpty) {
        return userResult.data!.first;
      } else {
        final userCloudResult = await NimCore.instance.userService
            .getUserListFromCloud([accountId]);
        if (userCloudResult.isSuccess &&
            userCloudResult.data != null &&
            userCloudResult.data!.isNotEmpty) {
          return userCloudResult.data!.first;
        }
      }
    }
  }
  return null;
}