MedicineOrder method

Future MedicineOrder({
  1. dynamic context,
  2. dynamic checkbox,
  3. dynamic userpackageId,
})

Implementation

Future MedicineOrder({context, checkbox, userpackageId}) async {
  var decodedResponse;
  final ApiBody = {
    "insert_id": previeworderdetails['results']['insert_id'],
    // "cart": previeworderCart,
    "check_use_wallet": "${checkbox}",
    "user_package_id": "${userpackageId}",
  };
  try {
    Map data = ApiBody;
    var body = jsonEncode(data);

    final response = await http.post(
      Uri.parse('${SDK_BASE_URL}medicine_api/order'),
      headers: {'Authorization': SignUpController.currentUserToken},
      body: body,
    );
    decodedResponse = json.decode(response.body);

    print("PLACE${decodedResponse}");
    if ("${decodedResponse['results']['status']}" == '200') {
      getpincodefromlocal();
      Get.off(MedicineHome());
      showDialog(
        barrierDismissible: false,
        context: context,
        builder: (BuildContext context) {
          return PinCodePopUp(
            messag: "${decodedResponse['results']['message']}",
            image: '${LottiePath}Order_Successful.json',
          );
        },
      );
    } else {
      getpincodefromlocal();
      Get.off(MedCartScreen());
      showDialog(
        barrierDismissible: false,
        context: context,
        builder: (BuildContext context) {
          return PinCodePopUp(
            messag: "${decodedResponse['results']['message']}",
            image: '${LottiePath}Order_Successful.json',
          );
        },
      );
    }
  } catch (e) {
    errorListner(
        apiname: 'medicine_api/order',
        responsed: "${decodedResponse}",
        request: "${ApiBody}",
        app_error: '${e}');
  }
}