identify static method

Future<void> identify({
  1. IdentificationCallback? onComplete,
  2. IdentificationFlowOptions? options,
})

Simplified single callback API (similar to MAUI IdentificationFlow.Run)

Presents the identification flow and calls the provided callback once with the result.

Parameters:

  • onComplete: Callback invoked when identification completes or fails
  • options: Optional identification settings to customize the flow behavior

Example:

await IdentificationFlow.identify(
  onComplete: (identified, customId, confidence, distance) {
    if (identified) {
      print('User identified: $customId');
    } else {
      print('No match found');
    }
  },
  options: IdentificationFlowOptions(
    livenessEnabled: true,
    securityLevel: 0.75,
  ),
);

Implementation

static Future<void> identify({
  IdentificationCallback? onComplete,
  IdentificationFlowOptions? options,
}) async {
  final streams = await present(options: options);

  // Listen for results
  streams['results']?.listen((result) {
    if (result is IdentificationResult) {
      onComplete?.call(
        identified: result.identified,
        customId: result.customId,
        confidence: result.confidence,
        distance: result.distance,
        imagePath: result.imagePath,
      );
    }
  });

  // Listen for errors
  streams['errors']?.listen((error) {
    if (error is String) {
      onComplete?.call(
        identified: false,
        customId: error,
        confidence: 0.0,
        distance: 0.0,
      );
    }
  });
}