loadNext method Null safety
override
Load next items asynchronously
Implementation
@override
Future<List<User>> loadNext() async {
if (loading) throw QueryInProgressError();
if (!hasNext) return [];
switch (queryType) {
case UserListQueryType.banned:
case UserListQueryType.muted:
if (channelType == null || channelUrl == null) {
throw InvalidParameterError();
}
break;
case UserListQueryType.participants:
if (channelUrl == null) throw InvalidParameterError();
break;
default:
break;
}
loading = true;
ApiRequest req;
switch (queryType) {
case UserListQueryType.filtered:
req = UserListRequest(
token: token,
limit: limit,
userIds: userIds,
);
break;
case UserListQueryType.banned:
req = BannedUserListRequest(
channelType: channelType!,
channelUrl: channelUrl!,
token: token,
limit: limit,
);
break;
case UserListQueryType.blocked:
req = BlockedUserListRequest(
token: token,
limit: limit,
);
break;
case UserListQueryType.muted:
req = MutedUserListRequest(
channelType: channelType!,
channelUrl: channelUrl!,
token: token,
limit: limit,
);
break;
case UserListQueryType.participants:
req = OpenChannelParticipantListRequest(
channelUrl: channelUrl!,
token: token,
limit: limit,
);
break;
}
final sdk = SendbirdSdk().getInternal();
final res = await sdk.api.send<UserListQueryResponse>(req);
loading = false;
token = res.next;
hasNext = res.next != '';
return res.users;
}