fetchContacts method

Future<EMCursorResult<EMContact>> fetchContacts({
  1. String? cursor,
  2. int pageSize = 20,
})

~english Gets the contact list from the server by page.

Param cursor The cursor of the page, the first page can be passed in null.

Param pageSize The size of the page.

Return The contact result.

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

~chinese 从服务器分页获取友。

Param cursor 分页的游标,第一页可以不传。

Param pageSize 分页的大小。

Return 好友列表获取结果。

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

Implementation

Future<EMCursorResult<EMContact>> fetchContacts({
  String? cursor,
  int pageSize = 20,
}) async {
  Map map = {"pageSize": pageSize};
  map.putIfNotNull('cursor', cursor);
  Map result = await _channel.invokeMethod(
    ChatMethodKeys.fetchContacts,
    map,
  );
  try {
    EMError.hasErrorFromResult(result);
    return EMCursorResult.fromJson(result[ChatMethodKeys.fetchContacts],
        dataItemCallback: (map) {
      return EMContact.fromJson(map);
    });
  } on EMError catch (e) {
    throw e;
  }
}