matchHumanFaces method
Future<String?>
matchHumanFaces({
- required int firstDocumentID,
- required int firstDocumentFaceIndex,
- required int secondDocumentID,
- required int secondDocumentFaceIndex,
override
Implementation
@override
Future<String?> matchHumanFaces({
required int firstDocumentID, // Use int for Long
required int firstDocumentFaceIndex,
required int secondDocumentID, // Use int for Long
required int secondDocumentFaceIndex,
}) async {
try {
// Invoke the native method with the given parameters
final String? result = await methodChannel.invokeMethod(
'matchHumanFaces',
{
'firstDocumentID': firstDocumentID, // Correct mapping
'firstDocumentFaceIndex': firstDocumentFaceIndex,
'secondDocumentID': secondDocumentID, // Correct mapping
'secondDocumentFaceIndex': secondDocumentFaceIndex,
},
);
// Log the result in debug mode
if (kDebugMode) {
print('Face detection completed successfully. Result: $result');
}
return result; // Return the result from the native layer
} on PlatformException catch (e) {
// Handle platform-specific exceptions and log error details
if (kDebugMode) {
print('Error detecting human faces: ${e.code} - ${e.message}');
if (e.details != null) {
print('Details: ${e.details}');
}
}
return null; // Return null in case of an error
} catch (e) {
// Handle any unexpected exceptions
if (kDebugMode) {
print('Unexpected error during face detection: ${e.toString()}');
}
return null; // Return null for unexpected errors
}
}