takePicture method
Implementation
Future<void> takePicture() async {
if (countBlink.value >= 5) {
XFile? file = await cameraService.takePicture();
imagePath.value = file?.path ?? '';
if (faceDetectorService.faceDetected.value) {
Face face = faceDetectorService.faces[0];
final leftEyeOpen = face.leftEyeOpenProbability ?? 0.2;
final rightEyeOpen = face.rightEyeOpenProbability?? 0.2;
isPictureTaken.value = true;
if (leftEyeOpen > 0.5 && rightEyeOpen > 0.5) {
if (Services.isVerify) {
disposeServices();
Get.back(result: {
"status":true,
"msg":"Success",
"data": cameraService.imagePath
});
} else {
CheckFace? user = await checkFacedata(File(cameraService.imagePath));
disposeServices();
if (user.status == true) {
Get.back(result: {
"status":true,
"msg":"Success",
"data": cameraService.imagePath
});
} else {
disposeServices();
Fluttertoast.showToast(
msg: "${user.msg}",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER);
Get.back(result: {
"status":false,
"msg":"${user.msg}"
});
}
}
} else {
disposeServices();
Fluttertoast.showToast(
msg: "Eyes are not fully open.",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER);
Get.back(result: {
"status":false,
"msg":"Eyes are not fully open."
});
}
}
} else {
Fluttertoast.showToast(
msg: "Blink you eyes ${2 - countBlink.value} more time",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER);
}
}