validatedEidBackFace static method

Future<bool> validatedEidBackFace({
  1. required File image,
})

Implementation

static Future<bool> validatedEidBackFace({required File image}) async {
  final textDetector = TextRecognizer(script: TextRecognitionScript.latin);
  final RecognizedText recognizedText =
      await textDetector.processImage(InputImage.fromFilePath(image.path));

  String textContent = recognizedText.text.toLowerCase();
  bool containsIssuingPlace = textContent.contains("issuing place");
  bool containsCardNumber = textContent.contains("card number");

  if (!containsIssuingPlace && !containsCardNumber) {
    return false;
  }

  RegExp sevenDigitsOrMore = RegExp(r'(\d{7,})');
  bool containsSevenDigitsOrMore = sevenDigitsOrMore.hasMatch(textContent);
  return containsSevenDigitsOrMore;
}