addContact method

Future<void> addContact(
  1. String userId,
  2. {String? reason}
)

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.

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;
  }
}