getAllContactsFromServer method Null safety

Future<List<String>> getAllContactsFromServer()

Gets all the contacts from the server.

Return The list of contacts.

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

Implementation

Future<List<String>> getAllContactsFromServer() async {
  Map result =
      await _channel.invokeMethod(ChatMethodKeys.getAllContactsFromServer);
  try {
    EMError.hasErrorFromResult(result);
    List<String> contacts = [];
    result[ChatMethodKeys.getAllContactsFromServer]?.forEach((element) {
      contacts.add(element);
    });
    return contacts;
  } on EMError catch (e) {
    throw e;
  }
}