medicineCancelOrder method

dynamic medicineCancelOrder({
  1. dynamic medicineOrderId,
  2. dynamic cancelReason,
  3. dynamic context,
})

Implementation

medicineCancelOrder({medicineOrderId, cancelReason, context}) async {
  var decodedResponse;
  final ApiBody = {
    "medicine_order_id": '$medicineOrderId',
    "cancellation_reason": cancelReason,
    "source": Platform.isAndroid ? '1' : '2',
  };
  var body = jsonEncode(ApiBody);

  http.Response response = await http.post(
      Uri.parse('${WELLNESS_URL}api/medicine/cancel-medicine-order'),
      headers: {
        "Content-Type": "application/json",
        'Authorization': currentUserToken,
      },
      body: body);
  decodedResponse = json.decode(response.body);
  Get.back();

  if (decodedResponse['success'] == true) {
    Get.back();
    showDialog(
        barrierDismissible: false,
        context: context,
        builder: (BuildContext context) {
          return MedicinePaymentSuccessPopup(
            fromPage: 'cancel_medicine',
            message: "${decodedResponse['message']}",
            image: "${FolderPath}Cancel_Order_Icon.svg",
            ontap: () {
              Get.back();
            },
          );
        });
  } else {
    Validator().errorMessage(
        context: context, message: "${decodedResponse['message']}");
  }
}