loadNext method Null safety

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

Load next items asynchronously

Implementation

@override
Future<List<OpenChannel>> loadNext() async {
  if (loading) throw QueryInProgressError();
  if (!hasNext) return [];

  loading = true;

  final options = [
    if (includeFrozenChannel) ChannelQueryIncludeOption.frozenChannel,
    if (includeMetaData) ChannelQueryIncludeOption.metaData
  ];

  final sdk = SendbirdSdk().getInternal();
  final res = await sdk.api.send<ChannelListQueryResponse<OpenChannel>>(
    OpenChannelListRequest(
      channelName: channelName,
      channelUrl: channelUrl,
      customType: customType,
      token: token,
      limit: limit,
      options: options,
    ),
  );

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