AddressCRUD method
Future
AddressCRUD({
- dynamic posttype,
- dynamic addressid,
- dynamic type,
- dynamic address,
- dynamic towerplotnum,
- dynamic societyname,
- dynamic pincode,
- dynamic city,
- dynamic state,
- dynamic name,
- dynamic email,
- dynamic mobile,
- dynamic landmark,
- dynamic fromscreen,
- dynamic context,
Implementation
Future AddressCRUD(
{posttype,
addressid,
type,
address,
towerplotnum,
societyname,
pincode,
city,
state,
name,
email,
mobile,
landmark,
fromscreen,
context}) async {
var decodedResponse;
final ApiBody = {
'post_type': '${posttype}',
'address_id': '${addressid}',
'type': '${type}',
'address': '${address}',
'tower_plot_no': '${towerplotnum}',
'society_name': '${societyname}',
'pincode': '${pincode}',
'city': '${city}',
'state': '${state}',
'name': '${name}',
'email': '${email}',
'mobile': '${mobile}',
'landmark': '${landmark}'
};
try {
final response = await http.post(
Uri.parse('${SDK_BASE_URL}medicine_api/add_user_address'),
headers: {'Authorization': SignUpController.currentUserToken},
body: ApiBody,
);
decodedResponse = json.decode(response.body);
if (decodedResponse['status'] == 200) {
fromscreen == 'Med'
? Get.to(AddressDisplay(
fromscreen: 'Med',
))
: Get.to(AddressDisplay(fromscreen: 'Test'));
Loading = 'end';
showDialog(
barrierDismissible: false,
context: context,
builder: (BuildContext context) {
return PinCodePopUp(
messag: "${decodedResponse['message']}",
image: '${LottiePath}Upload_Successful.json',
);
},
);
if (posttype == 'delete') {
(context as Element).reassemble();
} else {
null;
}
} else {
Loading = 'end';
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return PinCodePopUp(
messag: "Something Went Wrong",
image: '${LottiePath}Error.json',
);
},
);
}
} catch (e) {
errorListner(
apiname: 'medicine_api/add_user_address',
responsed: "${decodedResponse}",
request: "",
app_error: '${e}');
}
}