fetchAllContacts method

Future<List<EMContact>> fetchAllContacts()

~english Gets all contacts from the server.

Return The contact list.

Throws A description of the exception. See EMError. ~end

~chinese 从服务器获取所有的好友。

Return 好友列表。

Throws 如果有方法调用的异常会在这里抛出,可以看到具体错误原因。请参见 EMError。 ~end

Implementation

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