updateUserInfo method

Future<ChatUserInfo> updateUserInfo(
  1. {String? nickname,
  2. String? avatarUrl,
  3. String? mail,
  4. String? phone,
  5. int? gender,
  6. String? sign,
  7. String? birth,
  8. String? ext}

Modifies the user attributes of the current user.

Param nickname The nickname of the user.

Param avatarUrl The avatar URL of the user.

Param mail The email address of the user.

Param phone The phone number of the user.

Param gender The gender of the user. The value can only be 0, 1, or 2. Other values are invalid.

  • 0: (Default) Unknown;
  • 1: Male;
  • 2: Female. Param sign The signature of the user.

Param birth The birthday of the user.

Param ext The custom extension information of the user. You can set it to an empty string or type custom information and encapsulate them as a JSON string.

Return The user info.

Throws A description of the exception. See ChatError.


Future<ChatUserInfo> updateUserInfo({
  String? nickname,
  String? avatarUrl,
  String? mail,
  String? phone,
  int? gender,
  String? sign,
  String? birth,
  String? ext,
}) async {
  Map req = {};
  req.putIfNotNull("nickName", nickname);
  req.putIfNotNull("avatarUrl", avatarUrl);
  req.putIfNotNull("mail", mail);
  req.putIfNotNull("phone", phone);
  req.putIfNotNull("gender", gender);
  req.putIfNotNull("sign", sign);
  req.putIfNotNull("birth", birth);
  req.putIfNotNull("ext", ext);

  try {
    Map result =
        await _channel.invokeMethod(ChatMethodKeys.updateOwnUserInfo, req);
    ChatUserInfo info =
    _effectiveUserInfoMap[info.userId] = info;
    return info;
  } on ChatError catch (e) {
    throw e;