helpRequestSubmission method

Future helpRequestSubmission({
  1. dynamic requestType,
  2. dynamic context,
})

Implementation

Future helpRequestSubmission({requestType, context}) async {
  var decodedResponse;
  final ApiBody = {"request_type": "$requestType"};
  try {
    Map data = ApiBody;
    var body = jsonEncode(data);

    final response = await http.post(
      Uri.parse('${medicine_API}api/request-support'),
      headers: {
        'Authorization': currentUserToken,
        "Content-Type": "application/json",
      },
      body: body,
    );

    decodedResponse = json.decode(response.body);
    Get.back();
    if (decodedResponse['success'] == true) {
      // Get.offAll(HomePage());
      showDialog(
          context: context,
          barrierDismissible: false,
          builder: (BuildContext context) {
            return PinCodePopUp(
              messag: "${decodedResponse['message']}",
              image: '${LottiePath}Upload_Successful.json',
            );
          });
    } else {
      Validator().errorMessage(
          context: context, message: "${decodedResponse['message']}");
    }
  } catch (e) {
    ErrorListner(
        apiname: 'api/request-support',
        responsed: "${decodedResponse}",
        request: "${ApiBody}",
        app_error: '${e}');
  }
}