addContact method
~english Adds a new contact.
Param userId The user to be added.
Param reason (optional) The invitation message.
Throws A description of the exception. See ChatError. ~end
~chinese 添加联系人
Param userId 要添加的好友的用户 ID。
Param reason (可选)添加为好友的原因。
Throws 如果有方法调用的异常会在这里抛出,可以看到具体错误原因。请参见 ChatError。 ~end
Implementation
Future<void> addContact(
  String userId, {
  String? reason,
}) async {
  Map req = {
    'username': userId,
  };
  req.putIfNotNull("reason", reason);
  Map result = await _channel.invokeMethod(ChatMethodKeys.addContact, req);
  try {
    ChatError.hasErrorFromResult(result);
  } on ChatError catch (e) {
    throw e;
  }
}