getMedicineAddToCart method
Future
getMedicineAddToCart(
{ - dynamic cartData,
- dynamic context,
})
Implementation
Future getMedicineAddToCart({cartData, context}) async {
var decodedResponse;
final ApiBody = {"pincode": "${enteredPincode.value}", "cart": cartData};
var body = jsonEncode(ApiBody);
try {
http.Response response = await http.post(
Uri.parse('${WELLNESS_URL}api/medicine/medicine-cart-store'),
headers: {
"Content-Type": "application/json",
'Authorization': currentUserToken,
},
body: body,
);
decodedResponse = json.decode(response.body);
if (decodedResponse['success'] == true) {
getCartData = decodedResponse;
} else {
Validator().errorMessage(
context: context, message: "${decodedResponse['message']}");
}
} catch (e) {
print('Error adding to cart: $e');
}
}