saveReimbursementStatus method
dynamic
saveReimbursementStatus({
- dynamic packageId,
- dynamic reimbursent_Type,
- dynamic reimbursement_Amount,
- dynamic member_Id,
- dynamic name,
- dynamic relation,
- dynamic date_Birth,
- dynamic gender,
- dynamic context,
Implementation
saveReimbursementStatus({
packageId,
reimbursent_Type,
reimbursement_Amount,
member_Id,
name,
relation,
date_Birth,
gender,
context,
}) async {
var decodedResponse;
try {
var request = http.MultipartRequest(
'POST',
Uri.parse('${medicine_API}api/save-reimbursement-details'),
);
request.headers.addAll({"Authorization": currentUserToken});
request.fields['package_id'] = '$packageId';
request.fields['reimbursement_type'] = '$reimbursent_Type';
request.fields['reimbursement_amount'] = '$reimbursement_Amount';
request.fields['member_id'] = '';
request.fields['name'] = '$name';
request.fields['relation'] = '$relation';
request.fields['date_of_birth'] = '$date_Birth';
request.fields['gender'] = '$gender';
if (uploadedDocuments.isNotEmpty) {
for (int i = 0; i < uploadedDocuments.length; i++) {
request.fields['document_type[$i]'] =
await '${uploadedDocuments[i]['file_type']}';
request.files.add(await http.MultipartFile.fromPath(
"document[$i]",
uploadedDocuments[i]['file_path'].toString(),
));
}
}
var response = await request.send();
var responsed = await http.Response.fromStream(response);
decodedResponse = json.decode(responsed.body);
print(responsed.body);
Get.back();
if (decodedResponse['success'] == true) {
Get.back();
Get.offAll(MyProfileScreen());
Get.to(ReimbursementStatus());
await showDialog(
barrierDismissible: false,
context: context,
builder: (BuildContext context) {
return PinCodePopUp(
messag: "${decodedResponse['message']}",
image: '${LottiePath}Upload_Successful.json',
);
},
);
} else {
Get.back();
Validator().errorMessage(
context: context,
message: decodedResponse['message'] ?? "Something went wrong",
);
}
} catch (e) {
Validator().errorMessage(
context: context,
message: "${decodedResponse['message']}",
);
}
}