DocumentDetectorEvent.fromMap constructor

DocumentDetectorEvent.fromMap(
  1. Map map
)

Implementation

factory DocumentDetectorEvent.fromMap(Map map) {
  switch (map['event']) {
    case canceledEvent:
      return const DocumentDetectorEventClosed();
    case successEvent:
      return DocumentDetectorEventSuccess(
          captures: (map['captures'] as List?)
              ?.map((e) => Capture.fromMap(e))
              .toList(),
          documentType: map['documentType'],
          trackingId: map['trackingId']);
    case failureEvent:
      return DocumentDetectorEventFailure(
          errorType: map['errorType'],
          errorMessage: map['errorMessage'],
          securityErrorCode: map['securityErrorCode']);
  }
  throw Exception(resultMappingError);
}