fetchPinnedConversations method
Gets the list of pinned conversations from the server with pagination.
The SDK returns the pinned conversations in the reverse chronological order of their pinning.
Param cursor
The position from which to start getting data. If this parameter is not set, the SDK retrieves conversations from the latest pinned one.
Param pageSize
The number of conversations that you expect to get on each page. The value range is 1,50
.
Return The pinned conversation list of the current user.
Throws A description of the exception. See ChatError.
Implementation
Future<ChatCursorResult<ChatConversation>> fetchPinnedConversations({
String? cursor,
int pageSize = 20,
}) async {
Map map = {
"pageSize": pageSize,
};
map.putIfNotNull('cursor', cursor);
Map result = await ChatChannel.invokeMethod(
ChatMethodKeys.getPinnedConversationsFromServerWithCursor,
map,
);
try {
ChatError.hasErrorFromResult(result);
return ChatCursorResult.fromJson(
result[ChatMethodKeys.getPinnedConversationsFromServerWithCursor],
dataItemCallback: (map) {
return ChatConversation.fromJson(map);
});
} on ChatError catch (e) {
throw e;
}
}