fetchNext method
Future<List<CallLog> >
fetchNext({
- required dynamic onSuccess(),
- required dynamic onError(
- CometChatCallsException excep
Fetches the next batch of call logs.
The onSuccess function is called with a list of CallLog objects when the call logs are successfully fetched.
The onError function is called with a CometChatCallsException object when there is an error while fetching the call logs.
Returns a Future that resolves to a list of CallLog objects.
Implementation
Future<List<CallLog>> fetchNext({required Function(List<CallLog> callLogs) onSuccess, required Function(CometChatCallsException excep) onError}) async {
final userAuthToken = await _resolveAuthToken();
if (!CometChatCalls.isInitialized) {
onError(CometChatCallsException(ErrorCodeConstants.codeCometChatCallsSDKInitError, ErrorMessageConstants.messageCometChatCallsSDKInitError, ErrorDetailConstants.detailCometChatCallsSDKInitError));
return [];
} else if (userAuthToken == null) {
onError(CometChatCallsException(ErrorCodeConstants.codeUserAuthTokenNull, ErrorMessageConstants.messageCodeUserAuthTokenNull, ErrorDetailConstants.detailAuthTokenNull));
return [];
} else if (userAuthToken.isEmpty) {
onError(CometChatCallsException(ErrorCodeConstants.codeUserAuthTokenNull, ErrorMessageConstants.messageCodeUserAuthTokenBlankOrEmpty, ErrorDetailConstants.detailAuthKeyNullOrEmpty));
return [];
}
if (totalPages != 0 && totalPages == currentPage) {
onSuccess(<CallLog>[]);
return [];
}
ApiConnection().getCallLogList(params: getParams(true), authToken: userAuthToken, onSuccess: (String response) {
_getCallLogList(onSuccess, onError, response);
}, onError: (CometChatCallsException e) {
onError(e);
});
return [];
}