next method

  1. @override
Future<List<OpenChannel>> next()
override

Gets the list of next items.

Implementation

@override
Future<List<OpenChannel>> next() async {
  sbLog.i(StackTrace.current);

  if (isLoading) throw QueryInProgressException();
  if (!hasNext) return [];

  isLoading = true;

  final options = [
    if (includeFrozen) ChannelListQueryIncludeOption.includeFrozen,
    if (includeMetaData) ChannelListQueryIncludeOption.includeMetadata
  ];

  final res =
      await chat.apiClient.send<ChannelListQueryResponse<OpenChannel>>(
    OpenChannelListRequest(
      chat,
      limit: limit,
      nameKeyword: nameKeyword,
      urlKeyword: urlKeyword,
      customType: customTypeFilter,
      token: token,
      options: options,
    ),
  );

  for (final element in res.channels) {
    element.set(chat);
  }

  isLoading = false;
  token = res.next;
  hasNext = res.next != '';
  return res.channels;
}