fetchContacts method
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 ChatError.
Implementation
Future<ChatCursorResult<ChatContact>> fetchContacts({
String? cursor,
int pageSize = 20,
}) async {
Map map = {"pageSize": pageSize};
map.putIfNotNull('cursor', cursor);
Map result = await _channel.invokeMethod(ChatMethodKeys.fetchContacts, map);
try {
ChatError.hasErrorFromResult(result);
return ChatCursorResult.fromJson(
result[ChatMethodKeys.fetchContacts],
dataItemCallback: (map) {
return ChatContact.fromJson(map);
},
);
} on ChatError catch (e) {
throw e;
}
}