triggerCall method
Implementation
Future triggerCall() async {
url = (url ?? ('${hostName ?? HOSTNAME}:${port ?? PORT}'));
uri = isHttps ? Uri.https(url!, getEndpoint) : Uri.http(url!, getEndpoint);
log('$getOutgressLog Calling: $uri');
try {
log('Request: ${req.toRawJson()}');
final res = await restCall;
if (res.statusCode == 200) {
log('Response: ${res.body}');
if (!skipErrorRespCheck) {
ErrorResp error = ErrorResp.fromRawJson(res.body);
if (error.status == false) {
callContext.setError(error.error?.errorDescription);
if (showDefaultError) {
showErrorAlert(
error.error?.errorDescription ?? 'Unknown Error Occured');
}
return;
}
}
final resp = deserialiser(res.body);
callContext.data = resp;
} else if (res.statusCode == 404) {
callContext.setError('Unable to Connect to Server');
if (showDefaultError) showErrorAlert('Unable to Connect to Server');
} else {
callContext.setError(res.reasonPhrase);
if (showDefaultError) showErrorAlert(res.reasonPhrase);
}
} catch (e) {
if (showDefaultError) showErrorAlert('Unable to Connect to Server ');
callContext.setError(e.toString());
}
}