medicineAddAdress method

Future medicineAddAdress({
  1. dynamic addresstype,
  2. dynamic name,
  3. dynamic mobile,
  4. dynamic email,
  5. dynamic address,
  6. dynamic landmark,
  7. dynamic city,
  8. dynamic state,
  9. dynamic pincode,
  10. dynamic addressAction,
  11. dynamic context,
})

Implementation

Future medicineAddAdress(
    {addresstype,
    name,
    mobile,
    email,
    address,
    landmark,
    city,
    state,
    pincode,
    addressAction,
    context}) async {
  var decodedResponse;
  final ApiBody = {
    "address_id": addressAction,
    "name": "${name}",
    "mobile_no": "${mobile}",
    "email_id": "${email}",
    "type": "${addresstype}",
    "address": "${address}",
    "landmark": "${landmark}",
    "pincode": pincode,
    "city": "${city}",
    "state": "${state}"
  };
  try {
    Map data = ApiBody;
    var body = jsonEncode(data);

    final response = await http.post(
      Uri.parse('${WELLNESS_URL}api/medicine/store-user-address'),
      headers: {
        'Authorization': currentUserToken,
        "Content-Type": "application/json",
      },
      body: body,
    );
    decodedResponse = json.decode(response.body);
    Get.back();
    if (decodedResponse['success'] == true) {
      Get.to(MedicineAddressListPage());
      Validator().successMessage(
          context: context, message: "${decodedResponse['message']}");
    }
  } catch (e) {
    ErrorListner(
        apiname: 'api/medicine/store-user-address',
        responsed: "${decodedResponse}",
        request: "${ApiBody}",
        app_error: '${e}');
  }
}