AmbulancePickDrop method

dynamic AmbulancePickDrop({
  1. dynamic AddressLine1pick,
  2. dynamic AddressLine2pick,
  3. dynamic landmarkpick,
  4. dynamic pincodepick,
  5. dynamic statepick,
  6. dynamic citypick,
  7. dynamic AddressLine1drop,
  8. dynamic AddressLine2drop,
  9. dynamic landmarkdrop,
  10. dynamic pincodedrop,
  11. dynamic statedrop,
  12. dynamic citydrop,
  13. dynamic lat,
  14. dynamic long,
  15. dynamic context,
  16. dynamic userpackageid,
})

Implementation

AmbulancePickDrop(
    {AddressLine1pick,
    AddressLine2pick,
    landmarkpick,
    pincodepick,
    statepick,
    citypick,
    AddressLine1drop,
    AddressLine2drop,
    landmarkdrop,
    pincodedrop,
    statedrop,
    citydrop,
    lat,
    long,
    context,
    userpackageid}) async {
  var decodedResponse;
  final ApiBody = {
    "vendor_name": "package",
    "txt_pickup_address_1": '${AddressLine1pick}',
    "txt_pickup_address_2": '${AddressLine2pick}',
    "txt_pickup_landmark": '${landmarkpick}',
    "txt_pickup_pincode": '${pincodepick}',
    "txt_pickup_city": '${citypick}',
    "txt_pickup_state": '${statepick}',
    "txt_drop_address_1": '${AddressLine1drop}',
    "txt_drop_address_2": '${AddressLine2drop}',
    "txt_drop_landmark": '${landmarkdrop}',
    "txt_drop_pincode": '${pincodedrop}',
    "txt_drop_city": '${citydrop}',
    "txt_drop_state": '${statedrop}',
    "lat": '${lat}',
    "long": '${long}',
    "user_package_id": '${userpackageid}',
  };

  try {
    http.Response response = await http.post(
      Uri.parse('${SDK_BASE_URL}api/leads_request/ambulance_request'),
      headers: {
        "Authorization": SignUpController.currentUserToken,
      },
      body: ApiBody,
    );

    decodedResponse = json.decode(response.body);
    if (decodedResponse['status'] == 200) {
      Get.back();
      await showDialog(
        barrierDismissible: false,
        context: context,
        builder: (BuildContext context) {
          return PinCodePopUp(
            messag: "${decodedResponse['message']}",
            image: '${LottiePath}Order_Successful.json',
          );
        },
      );
      Get.back();
      Get.back();
    } else {
      Get.back();
      showDialog(
        barrierDismissible: false,
        context: context,
        builder: (BuildContext context) {
          return PinCodePopUp(
            messag: "${decodedResponse['message']}",
            image: '${LottiePath}Error.json',
          );
        },
      );
    }
  } catch (e) {
    errorListner(
        apiname: 'api/leads_request/ambulance_request',
        responsed: "${decodedResponse}",
        request: '${ApiBody}',
        app_error: '${e}');
  }
}