CancelAppointment method

Future CancelAppointment({
  1. dynamic diagnostic_order_id,
  2. dynamic cancel_reason,
  3. dynamic context,
})

Implementation

Future CancelAppointment(
    {diagnostic_order_id, cancel_reason, context}) async {
  var decodedResponse;
  final ApiBody = {
    "diagnostic_order_id": "${diagnostic_order_id}",
    "cancel_reason": "${cancel_reason}"
  };
  try {
    Map data = ApiBody;
    var body = jsonEncode(data);
    final response = await http.post(
        Uri.parse('${WELLNESS_URL}api/diagnostic/cancel-order'),
        body: body,
        headers: {
          'Authorization': currentUserToken,
          "Content-Type": "application/json"
        });
    decodedResponse = json.decode(response.body);
    if (decodedResponse['success'] == true) {
      await showDialog(
          barrierDismissible: false,
          context: context,
          builder: (BuildContext context) {
            return MedicinePaymentSuccessPopup(
              fromPage: 'cancel_medicine',
              message: "${decodedResponse['message']}",
              image: "${FolderPath}Cancel_Order_Icon.svg",
              ontap: () async {
                Get.back();
                Get.back();
                Get.back();
                Get.back();
              },
            );
          });
      Get.back();
      diagnostic_order_id = await TestviewDetails['order_id'];
      Get.to(DiagnosticsOrderDetails(apiReload: true),
          transition: Transition.noTransition, preventDuplicates: false);
    } else {
      Get.back();
      Get.back();
      Get.back();
      Validator().errorMessage(
          context: commonContext, message: "${decodedResponse['message']}");
    }
  } catch (e) {
    print(e);
    ErrorListner(
        apiname: 'api/diagnostic/cancel-order',
        responsed: "${decodedResponse}",
        request: "",
        app_error: '${e}');
  }
}