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
  ];

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

    token = res.next;
    hasNext = res.next != '';
    for (final element in res.channels) {
      element.set(chat);
    }
  } catch (_) {
    isLoading = false;
    rethrow;
  }

  isLoading = false;
  return res.channels;
}