SDK Lifecycle
DocumentDetectorEvent (Flutter)
The DocumentDetectorEvent in Flutter represents the different outcomes of the document detection process. Below are the events you can handle during the SDK's document detection lifecycle:
Event
Description
DocumentDetectorEventClosed
Triggered when the user cancels the document capture process, such as pressing the close button.
DocumentDetectorEventSuccess
Called when the document is successfully captured, providing details like captures, documentType, and trackingId.
DocumentDetectorEventFailure
Triggered when the document capture process fails, with error details like errorType, errorMessage, and securityErrorCode.
Example Implementation
Below is an example of how to handle DocumentDetectorEvent events in Flutter:
void _setupDocumentDetectorListener(Stream<DocumentDetectorEvent> stream) {
stream.listen((event) {
if (event is DocumentDetectorEventClosed) {
print('Document capture process was closed by the user.');
} else if (event is DocumentDetectorEventSuccess) {
print('Success! Captures: ${event.captures}, '
'Document type: ${event.documentType}, '
'Tracking ID: ${event.trackingId}');
} else if (event is DocumentDetectorEventFailure) {
print(
'Failure! Error type: ${event.errorType}, '
'Error message: ${event.errorMessage}, '
'Security error code: ${event.securityErrorCode}',
);
}
});
}Atualizado

