process method
Future<int>
process(
- String text,
- XFile file,
- BuildContext context,
- dynamic png,
- String? cardType,
Implementation
Future<int> process(String text, XFile file, BuildContext context, final png,
String? cardType) async {
Map<String, String?> idCardData = idCardModel.textToIdCard(
text,
inputName: name,
inputFatherName: fatherName,
inputCountry: country,
inputGender: gender,
inputIdCardNumber: idCardNumber,
inputBirthDate: birthDate,
inputExpiryDate: expiryDate,
inputIssueDate: issueDate,
);
// Map<String, String?> idCardDataClone = Map.from(idCardData);
name = idCardData['name'] ?? name;
fatherName = idCardData['father_name'] ?? fatherName;
idCardNumber = idCardData['id_card_number'] ?? idCardNumber;
expiryDate = idCardData['date_of_expiry'] ?? expiryDate;
issueDate = idCardData['date_of_issue'] ?? issueDate;
birthDate = idCardData['date_of_birth'] ?? birthDate;
gender = idCardData['gender'] ?? gender;
country = idCardData['country'] ?? country;
// if (idCardData.values.any((element) => element == null)) {
// return 0;
// } else {
// final contours = dylib.lookupFunction<Void Function(Pointer<Utf8>),
// void Function(Pointer<Utf8>)>('Contours');
// try {
// if (!(text.toLowerCase().contains('name') ||
// text.toLowerCase().contains('father') ||
// text.toLowerCase().contains('gender') ||
// text.toLowerCase().contains('country'))) {
// profileController.message.value == null;
// // if (captureBackSide) {
// // contours(file.path.toNativeUtf8());
// // backImage = Image.file(File(XFile(file.path).path));
// if (backImage == null) {
// contours(file.path.toNativeUtf8());
// backImage = Image.file(File(XFile(file.path).path));
//
// // var png =
// // img.encodePng((await utils.detectObjectsCropSaveImage(file))!);
// //
// // Uint8List bytes = Uint8List.fromList(png);
// // backImage = Image(
// // image: MemoryImage(bytes),
// // );
// }
// // }
// // Future.delayed(const Duration(seconds: 2)).then((value) {
// // captureBackSide = true;
// // });
// // return 0;
// } else {
// if (!isFrontCaptured) {
// // contours(file.path.toNativeUtf8());
// // frontImage = Image.file(File(XFile(file.path).path));
// // frontImage = await utils.detectObjectsCropSaveImage(file.path);
// // int i = 0;
// img.Image? cropped;
// // while (cropped != null || i < 3) {
// // i++;
// cropped = await utils.detectObjectsCropSaveImage(file);
// if (cropped != null) {
// var png = img.encodePng(cropped);
// Uint8List bytes = Uint8List.fromList(png);
// // file = XFile.fromData(bytes);
// // XFile result = XFile.fromData(bytes).;
// // File res2 = File.fromRawPath(bytes);
// // contours(file.path.toNativeUtf8());
// // frontImage = Image.file(File(file.path));
// frontImage = Image(image: MemoryImage(bytes));
//
// // frontImage = Image(image: MemoryImage(bytes));
// isFrontCaptured = true;
// Future.delayed(const Duration(milliseconds: 500));
// }
// // }
// }
// retry++;
// if (retry == 3) {
// profileController.message.value = 'Unable to find back side';
// return 3;
// }
// profileController.message.value = 'Flip your card';
// return 2;
// }
// profileController.message.value = null;
// Navigator.pushReplacement((context), MaterialPageRoute(builder: (_) {
// return IdCardProfile(
// image: png,
// cardImage: frontImage,
// backSide: backImage,
// idCardData: idCardData,
// cardType: 'Id Card');
// }));
// } catch (e) {
// profileController.message.value = null;
// print('-------------------------exception');
// Navigator.pushReplacement(context, MaterialPageRoute(builder: (_) {
// return IdCardProfile(
// image: png,
// cardImage: frontImage,
// backSide: backImage,
// idCardData: idCardData,
// cardType: 'Id Card');
// }));
// }
// }
return 1;
}