loadNext method Null safety
override
Load next items asynchronously
Implementation
@override
Future<List<BaseMessage>> loadNext() async {
if (loading) throw QueryInProgressError();
if (!hasNext) return [];
loading = true;
final sdk = SendbirdSdk().getInternal();
final res = await sdk.api.send<MessageSearchQueryResponse>(
MessageSearchRequest(
keyword: keyword,
channelUrl: channelUrl,
customType: channelCustomType,
reverse: reverse,
exactMatch: exactMatch,
beforeIndex: beforeIndex,
afterIndex: afterIndex,
token: token,
targetUserIds: targetUserIds,
startAt: messageTimestampFrom,
endAt: messageTimestampTo,
sortField: messageSearchQueryOrderEnumMap[order],
limit: limit,
advanced: advancedQuery,
targetFields: targetFields,
),
);
loading = false;
token = res.next;
hasNext = res.hasNext;
return res.results;
}