checkPincode method

Future checkPincode(
  1. dynamic pincode
)

Implementation

Future checkPincode(
  pincode,
) async {
  var decodedResponse;

  try {
    final response = await http.get(
      Uri.parse(
          '${WELLNESS_URL}api/medicine/city/serviceable?pincode=$pincode'),
      headers: {'Authorization': currentUserToken},
    );

    decodedResponse = json.decode(response.body);
    isPincodeValidMessage = decodedResponse['message'];
    if (decodedResponse['success'] == true) {
      isPincodeValid = 1;
      Get.back();
      city.value = decodedResponse['city'];
      enteredPincode.value = pincode.toString();
      SharedPreferences _prefs = await SharedPreferences.getInstance();
      await _prefs.setString('city', decodedResponse['city'].toString());
      await _prefs.setString('pincodefromuser', pincode.toString());
      await getpincodefromlocal();
    } else {
      isPincodeValid = 2;
      Get.back();
    }
  } catch (e) {
    ErrorListner(
        apiname: 'api/medicine/city/serviceable?pincode=$pincode',
        responsed: "${decodedResponse}",
        request: "",
        app_error: '${e}');
  }
}