id_document_scanner library
Camera-based ID card scanner with a customizable overlay and on-device, pure-Dart document detection (no ML Kit or cloud services).
Classes
- CaptureValidation
- What your CaptureValidator answers for a capture.
- CardCorners
- The 4 corners of the card found in a photo, normalized to it (0..1).
- CardEdgeRefiner
- Finds the exact card outline in a full photo, starting from where the live analysis saw it. Each side is sampled across a narrow band, the strongest consistent edge is kept per sample and a straight line is fitted through them; the 4 line intersections are the card corners (so a slightly tilted or perspective-distorted card is still cropped exactly).
- CroppedCard
- Result of cropping the card out of a photo.
- DetectionConfig
-
Thresholds used to decide whether the card is ready to be captured.
Defaults were tuned for ID-1 cards on mid-range phones; adjust them with
showDebugInfo: trueif your devices or documents behave differently. - DetectionStabilizer
- Requires several consecutive ready frames with the card barely moving before the scanner auto-captures, so the photo is not taken mid-motion.
- DocumentCapture
- Photo taken once the card was aligned and stable.
- DocumentCropper
- Crops the card and its fields out of captured photos, off the UI isolate.
- DocumentTemplate
- Where each field is printed on one face of a card, in coordinates normalized to the card (0..1, origin top-left, card upright). Used to crop fields for OCR.
- DocumentVerification
- Result of checking a capture against the Paraguayan identity card.
- EdgeMeasurement
- How well one side of the card lines up with the guide frame.
- FittedLine
-
Straight line
across = slope * along + intercept, fitted to edge points with outlier rejection (text or patterns near the card border). - FrameAnalysis
-
Result of analysing one frame. Exposed so integrators can calibrate
DetectionConfig on real devices (see
showDebugInfo). - FrameAnalyzer
- Pure-Dart detector: decides whether an ID-1 card fills the guide frame, using only the luminance plane (no ML, no native OCR).
- GuideGeometry
- Converts between the guide frame drawn on screen and the camera image.
- IdDocumentScanner
- Full-screen camera with a card-shaped guide. The frame turns green when the document is aligned, sharp and well lit, and (with auto-capture) the photo is taken once it stays steady.
- IdDocumentScannerController
- Owns the camera and the scanning flow.
- LumaFrame
- Luminance (Y) plane of a camera frame as delivered by the sensor, plus the rotation needed to show it upright.
- MrzCheckDigit
- ICAO 9303 check digit (weights 7-3-1, modulo 10).
- MrzConstants
- ICAO 9303 TD1 layout (ID cards: 3 lines of 30 characters).
- MrzData
- Data read from a TD1 machine readable zone, with the result of each ICAO check digit.
- MrzParser
- Parses and validates a TD1 MRZ (ID cards), tolerating the usual OCR confusions: in fields that can only hold digits, letters that look like digits are corrected before validating.
- MrzReader
- Pure-Dart OCR for the TD1 machine readable zone.
- MrzReading
- Text read from the MRZ of a card image.
- ParaguayIdTemplates
- Field layouts of the Paraguayan "Cédula de Identidad Civil".
- ParaguayIdVerifier
- Checks that a cropped card really is a Paraguayan "Cédula de Identidad".
- ReproductionCheck
- Result of looking for signs that the photo is of a screen or a printout instead of the physical card.
- ReproductionDetector
- Detects photos of a screen or of a printed copy of the card, without asking the user for anything.
- ScannerConstants
- Fixed values shared by the scanner. Everything tunable per integration lives in DetectionConfig / ScannerOverlayStyle; these are the defaults.
- ScannerMessages
- Text shown for each ScanStatus. Pass your own (e.g. from your l10n) to translate or change the tone; defaults are Paraguayan Spanish.
- ScannerOverlay
- Default overlay: dimmed surroundings and a card-shaped frame that opens with an entry animation, breathes and sweeps a scan line while searching, glows green when ready and traces its border while the card is held steady.
- ScannerOverlayState
-
What a custom
overlayBuilderreceives to draw its own UI. - ScannerOverlayStyle
- Look of the guide frame and message. Pass your app palette colors here.
- ScanResult
- All accepted captures once every side of the flow was scanned.
Enums
- CaptureValidationStatus
- Outcome of validating a capture (e.g. with your backend).
- DocumentField
- Data fields printed on either face of a supported identity card.
- DocumentRejectionReason
- Why a capture was not recognised as a Paraguayan identity card.
- DocumentSide
- Which face of the card is being scanned.
- DocumentType
- Supported identity documents. Both share the ID-1 card format, so detection is the same; the type only selects the field template used after capture.
- DocumentVerificationStatus
- Outcome of checking that a capture is a Paraguayan identity card.
- MrzSex
- Sex as encoded in the MRZ ("M", "F" or "<").
- ScanStatus
- What the scanner currently sees inside the guide frame.
Typedefs
-
CaptureValidator
= FutureOr<
CaptureValidation> Function(DocumentCapture capture) - Called with every capture before moving on. Upload the cropped card to your backend here and answer whether the flow can continue.