SmartWatchApi method

dynamic SmartWatchApi({
  1. dynamic AddressLine1pick,
  2. dynamic AddressLine2pick,
  3. dynamic landmarkpick,
  4. dynamic pincodepick,
  5. dynamic statepick,
  6. dynamic citypick,
  7. dynamic lat,
  8. dynamic long,
  9. dynamic mobile,
  10. dynamic context,
  11. dynamic userpackageid,
  12. dynamic module_id,
})

Implementation

SmartWatchApi(
    {AddressLine1pick,
    AddressLine2pick,
    landmarkpick,
    pincodepick,
    statepick,
    citypick,
    lat,
    long,
    mobile,
    context,
    userpackageid,
    module_id}) 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}',
    "lat": '${lat}',
    "long": '${long}',
    "mobile_no": '${mobile}',
    "user_package_id": '${userpackageid}',
    "module_id": '${module_id}'
  };

  try {
    http.Response response = await http.post(
      Uri.parse('${SDK_BASE_URL}api/leads_request/boat_watch_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}Upload_Successful.json',
          );
        },
      );
      await Navigator.popAndPushNamed(context, '/wellnesspage');
    } else {
      BackFunction(2);

      showDialog(
        barrierDismissible: false,
        context: context,
        builder: (BuildContext context) {
          return PinCodePopUp(
            messag: "${decodedResponse['message']}",
            image: '${LottiePath}Error.json',
          );
        },
      );
    }
  } catch (e) {
    errorListner(
        apiname: 'api/leads_request/boat_watch_request',
        responsed: "${decodedResponse}",
        request: '${ApiBody}',
        app_error: '${e}');
  }
}