fetchNext method
Future<List<GroupMember> >
fetchNext({
- required dynamic onSuccess(
- List<
GroupMember> groupList
- List<
- required dynamic onError(
- CometChatException excep
Fetch the list of Users that logged-in user have blocked.
Android Reference: BannedGroupMembersRequest.fetchNext()
Implementation
Future<List<GroupMember>> fetchNext({
required Function(List<GroupMember> groupList)? onSuccess,
required Function(CometChatException excep)? onError,
}) async {
try {
if (guid.isEmpty) {
final error = CometChatException(
ErrorCode.errorInvalidGuid,
'GUID cannot be empty',
'GUID cannot be empty',
);
if (onError != null) onError(error);
return [];
}
if (limit > _maxLimit) {
final error = CometChatException(
ErrorCode.errorLimitExceeded,
'Limit cannot exceed $_maxLimit',
'Limit cannot exceed $_maxLimit',
);
if (onError != null) onError(error);
return [];
}
if (_nextPage > _totalPages && _totalPages != 0) {
if (onSuccess != null) onSuccess([]);
return [];
}
final sdk = SdkRegistry.getInstance();
final result = await sdk.bannedMembers.getBannedMembers(
guid,
limit: limit,
cursor: _cursor != 0 ? _cursor : null,
page: _nextPage > 0 ? _nextPage : null,
searchKeyword: searchKeyword,
scopes: scopes,
);
if (result.pagination != null) {
if (result.pagination!.totalPages != null) {
_totalPages = result.pagination!.totalPages!;
}
if (result.pagination!.currentPage != null) {
_currentPage = result.pagination!.currentPage!;
_nextPage = _currentPage + _pageOffset;
}
}
if (result.nextCursor != null) {
_cursor = result.nextCursor!;
key = _cursor.toString();
}
if (onSuccess != null) {
onSuccess(result.members);
}
return result.members;
} on sdk_errors.SdkException catch (sdkEx) {
final cometChatEx = CometChatException(
sdkEx.code,
sdkEx.details ?? sdkEx.message,
sdkEx.message,
);
if (onError != null) {
onError(cometChatEx);
}
} catch (e) {
final cometChatEx = CometChatException(
ErrorCode.errorUnhandledException,
e.toString(),
e.toString(),
);
if (onError != null) {
onError(cometChatEx);
}
}
return [];
}