addContact method Null safety

Future<void> addContact(
  1. String username,
  2. [String reason = '']
)

Adds a new contact.

Param username The user to be added.

Param reason (optional) The invitation message.

Throws A description of the exception. See {@link EMError}.

Implementation

Future<void> addContact(
  String username, [
  String reason = '',
]) async {
  Map req = {'username': username, 'reason': reason};
  Map result = await _channel.invokeMethod(ChatMethodKeys.addContact, req);
  try {
    EMError.hasErrorFromResult(result);
  } on EMError catch (e) {
    throw e;
  }
}