fetchUserInfoByIdWithType method Null safety

  1. @Deprecated('Use userInfoManager.fetchUserInfoByIdWithExpireTime() method instead.')
Future<Map<String, EMUserInfo>> fetchUserInfoByIdWithType(
  1. List<String> userIds,
  2. List<EMUserInfoType> types,
  3. {int expireTime = 3600}
)
@Deprecated('Use userInfoManager.fetchUserInfoByIdWithExpireTime() method instead.')

获取指定id的用户的指定类型的用户属性 userIds 需要获取的环信id; types 需要获取的属性 expireTime 过期时间,单位秒。如果之前获取过, 如果距当前时间小于过期时间则不会重复获取

Implementation

@Deprecated(
    'Use userInfoManager.fetchUserInfoByIdWithExpireTime() method instead.')
Future<Map<String, EMUserInfo>> fetchUserInfoByIdWithType(
    List<String> userIds, List<EMUserInfoType> types,
    {int expireTime = 3600}) async {
  List<int> userInfoTypes = [];
  types.forEach((element) {
    int type = _userInfoTypeToInt(element);
    userInfoTypes.add(type);
  });

  List<String> reqIds = userIds
      .where((element) =>
          !_effectiveUserInfoMap.containsKey(element) ||
          (_effectiveUserInfoMap.containsKey(element) &&
              DateTime.now().millisecondsSinceEpoch -
                      _effectiveUserInfoMap[element]!.expireTime >
                  expireTime * 1000))
      .toList();
  Map resultMap = Map();

  Map req = {'userIds': reqIds, 'userInfoTypes': userInfoTypes};
  Map result =
      await _channel.invokeMethod(EMSDKMethod.fetchUserInfoByIdWithType, req);

  EMError.hasErrorFromResult(result);
  result[EMSDKMethod.fetchUserInfoByIdWithType].forEach((key, value) {
    EMUserInfo eUserInfo = EMUserInfo.fromJson(value);
    resultMap[key] = eUserInfo;

    _effectiveUserInfoMap[key] = eUserInfo;
  });

  return resultMap as FutureOr<Map<String, EMUserInfo>>;
}