fetchJoinedChatThreads method Null safety

Future<ChatCursorResult<ChatThread>> fetchJoinedChatThreads(
  1. {String? cursor,
  2. int limit = 20}
)

Paging to get the list of Chat Threads that the current user has joined from the server

Param cursor The initial value can be empty or empty string.

Param limit The number of fetches at one time. Value range (0, 50].

Return Returns the result of {@link ChatCursorResult}), including the cursor for getting data next time and the chat thread object list.

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

Implementation

Future<ChatCursorResult<ChatThread>> fetchJoinedChatThreads({
  String? cursor,
  int limit = 20,
}) async {
  Map req = {"pageSize": limit};
  req.setValueWithOutNull("cursor", cursor);
  Map result =
      await _channel.invokeMethod(ChatMethodKeys.fetchJoinedChatThreads, req);
  try {
    ChatError.hasErrorFromResult(result);
    return ChatCursorResult.fromJson(
        result[ChatMethodKeys.fetchJoinedChatThreads],
        dataItemCallback: (map) {
      return ChatThread.fromJson(map);
    });
  } on ChatError catch (e) {
    throw e;
  }
}