verificationCheck method
Implementation
Future<LivelinessReturnModel> verificationCheck(
String file,
Liveliness mlValue,
File cropFile
) async {
var postData = {"file": file, "image_id": "${DateTime.now().microsecond}"};
try {
final response= await http.post(Uri.parse(UrlResources.faceVerificationCheck),
body: postData, headers: {
"document-access-token": accessToken,
});
if (response.statusCode == 200) {
Liveliness res=Liveliness.fromJson(response.body.toString());
if (res.isSuccess || res.message == "Couldn't identify direction") {
LivelinessReturnModel data = LivelinessReturnModel(
status: true,
direction: mlValue.direction,
img: cropFile);
return data;
}else{
LivelinessReturnModel data = LivelinessReturnModel(
status: false,
direction: mlValue.direction,
img: cropFile);
return data;
}
} else {
showErrorToast(
"Something went wrong,please try ",
);
throw Exception();
}
} on TimeoutException catch (e) {
showErrorToast(
"Connection timeout, please try again",
);
throw Exception();
} on SocketException catch (e) {
showErrorToast(
"Please check your network connection",
);
throw Exception();
} on Error catch (e) {
showErrorToast(
"Something went wrong",
);
throw Exception();
}
}