UploadDignoprescription method
Future
UploadDignoprescription(
{ - dynamic img,
- dynamic context,
})
Implementation
Future UploadDignoprescription({img, context}) async {
var decodedResponse;
try {
var request = http.MultipartRequest(
'POST', Uri.parse('${SDK_BASE_URL}home_api/upload_prescription'));
request.headers
.addAll({"Authorization": "${SignUpController.currentUserToken}"});
request.fields['type'] = 'diagnostics';
request.files.add(
await http.MultipartFile.fromPath("prescription_file", "${img}"));
var response = await request.send();
var responsed = await http.Response.fromStream(response);
var decodedResponse = json.decode(responsed.body);
if (decodedResponse['status'] == 200) {
Get.back();
showDialog(
context: context,
builder: (BuildContext context) {
return SuccessUploadPrescription();
},
);
} else {
Get.back();
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return PinCodePopUp(
messag: "${decodedResponse['message']}",
image: '${LottiePath}Error.json',
);
},
);
}
} catch (e) {
errorListner(
apiname: 'home_api/upload_prescription',
responsed: "${decodedResponse}",
request: '',
app_error: '${e}');
}
}