TestAddToCart method
Future
TestAddToCart(
{ - dynamic test_id,
- dynamic package_id,
- dynamic context,
})
Implementation
Future TestAddToCart({test_id, package_id, context}) async {
var decodedResponse;
final ApiBody = {"test_id": test_id, "package_id": package_id};
try {
Map data = ApiBody;
var body = jsonEncode(data);
final response = await http.post(
Uri.parse('${WELLNESS_URL}api/diagnostic/diagnostic-cart'),
headers: {
'Authorization': currentUserToken,
"Content-Type": "application/json"
},
body: body,
);
decodedResponse = json.decode(response.body);
if (decodedResponse['success'] == true) {
return null;
} else {
Validator().errorMessage(
context: context, message: "${decodedResponse['message']}");
}
} catch (e) {
ErrorListner(
apiname: 'api/diagnostic/diagnostic-cart',
responsed: "${decodedResponse}",
request: "${ApiBody}",
app_error: '${e}');
}
}