fetchOwnInfo method Null safety
- {int expireTime = 0}
Gets the current user's attributes from the server.
Param expireTime
The time period(seconds) when the user attibutes in the cache expire. If the interval between two calles is less than or equal to the value you set in the parameter, user attributes are obtained directly from the local cache; otherwise, they are obtained from the server. For example, if you set this parameter to 120(2 minutes), once this method is called again within 2 minutes, the SDK returns the attributes obtained last time.
Return The user properties that are obtained. See {@link EMUserInfo}.
Throws A description of the exception. See {@link EMError}.
Implementation
Future<EMUserInfo?> fetchOwnInfo({int expireTime = 0}) async {
String? currentUser = await EMClient.getInstance.getCurrentUsername();
if (currentUser != null) {
try {
Map<String, EMUserInfo> ret = await fetchUserInfoById(
[currentUser],
expireTime: expireTime,
);
_ownUserInfo = ret.values.first;
} on EMError catch (e) {
throw e;
}
}
return _ownUserInfo;
}