scanner library
The camera scanner: BarcodeScanner with templates and themes, its ScannerController, and the glass widgets to build your own scanner UI.
A layer on top of core.dart, content.dart and rendering.dart,
which it exports too.
Classes
- Barcode
- A barcode found in an image or a camera frame.
- BarcodeCaption
- Text drawn with a barcode: BarcodeStyle.title above it, BarcodeStyle.caption under it. On screen and in the PNG and SVG exports alike.
- BarcodeCapture
- Barcodes found in one camera frame.
- BarcodeCard
- A rounded plate under a barcode and its text: BarcodeStyle.card.
- BarcodeContent
- The payload of a Barcode, parsed into a typed value.
- BarcodeError
- Why a barcode was found but could not be decoded.
- BarcodeImage
- A created barcode as an 8-bit grayscale raster (0 = black, 255 = white).
- BarcodeInput
-
What
BarcodeWriteraccepts for a format (BarcodeFormat.input): a description for a form field, an example that encodes, and the kind of keyboard. - BarcodeListSheet
- A sheet listing scanned codes with counts, the latest first and highlighted, and a "Done" button.
- BarcodeLogo
- An image placed in the middle of a QR code.
- BarcodeOutlines
- Outlines the barcodes in ScannerLayout.barcodes in the accent color.
- BarcodePosition
- The four corners of a barcode, in pixels of the source image.
- BarcodeReader
- Reads barcodes from images: photos, files, screenshots, raw pixels.
- BarcodeResultSheet
- The result sheet of a scanned code: its kind ("LINK"), a title, details, the raw text, the symbology and buttons.
- BarcodeScanner
- A camera preview that scans barcodes.
- BarcodeSequence
- One symbol of a structured append sequence (a message split across several barcodes).
- BarcodeStyle
-
How a barcode is drawn: by
BarcodeView, and by toPng, toSvg, encodePng and encodeSvg when exported. - BarcodeSymbol
- An encoded barcode: the module matrix plus what is needed to render it.
- BarcodeThumbnail
- The picture of a scanned barcode, for result sheets and lists of scans: the sharpest picture that is still exactly the code scanned.
- BarcodeView
- Shows a barcode. Drawn as vectors from the module matrix, so it is sharp at any size and pixel density.
- BarcodeWriter
- Creates barcodes from text or binary data.
- BinaryContent
- Binary data.
- BoardingPassContent
- An airline boarding pass (IATA Bar Coded Boarding Pass, Resolution 792): the passenger and one leg per flight.
- BoardingPassLeg
- One flight of a BoardingPassContent.
- CollectedBarcode
- A code in a BarcodeListSheet and how often it was scanned.
- ContactContent
- A contact card (vCard or MeCard).
- ContentIssue
- A problem that keeps BarcodeContent.toPayload from building a value, from BarcodeContent.validate.
- CryptoContent
- A cryptocurrency payment request: an address, optionally with an amount.
- DriverLicenseContent
- A North American driver's license or ID card (AAMVA DL/ID standard, the PDF417 on the back).
- EmailContent
-
An e-mail draft (
mailto:,MATMSG:,SMTP:). - EmvPaymentContent
-
An EMVCo merchant-presented QR code (EMV QRCPS): the format of PIX,
PayNow, PromptPay, QRIS, VietQR, DuitNow and many other national
schemes.
000201…6304XXXX. - EpcPaymentContent
-
A SEPA credit transfer (EPC QR code, "GiroCode", EPC069-12):
BCD\n002\n1\nSCT\n…. Always in euros. - EsimContent
-
An eSIM activation code (
LPA:1$smdp.example.com$MATCHING-ID, GSMA SGP.22): where the phone downloads the profile from. - EventContent
- A calendar event (vEvent).
- GeoContent
-
A location (
geo:). - GostPaymentContent
-
A Russian bank transfer (ГОСТ Р 56042-2014):
ST00012|Name=…|…. - Gs1Content
- GS1 data: Application Identifiers and their values.
- OtpContent
-
A one-time password account for an authenticator app
(
otpauth://totp/Issuer:account?secret=…&issuer=Issuer, the Key URI format of Google Authenticator). - PaymentContent
- A payment request: who to pay, into which account, how much and what for. One subclass per standard, each with its own fields; the getters here are what every standard has, so that one screen can show any of them:
- PhoneContent
-
A phone number to call (
tel:,facetime:,facetime-audio:). - PickImageButton
- A glass button that lets the user pick a photo and reads the codes in it with ScannerController.readImage: they are reported like the camera's.
- PixelBuffer
- Raw pixels to read barcodes from: a video frame, a frame from another camera plugin, a rendered widget, a decoded image.
- ProductContent
- A retail product number from an EAN-13, EAN-8, UPC-A or UPC-E barcode: the GTIN, and the ISBN or ISSN when the number is a book or a periodical (prefixes 978/979 and 977).
- ReaderOptions
- How thoroughly the engine searches an image.
- ScanFieldButton
- A button for a text field that fills it from a barcode: it opens a scanner in a sheet (scanBarcode), puts the code into controller and closes.
- ScannerAction
- A button of a BarcodeResultSheet.
- ScannerActionButton
- A full-width button of a result sheet: primary in the accent, or outlined.
- ScannerActions
- The buttons of a sheet: side by side when they fit, else stacked.
- ScannerBadge
- A rounded square with an icon in the accent, as next to a Wi‑Fi network's name.
- ScannerButton
- A 48 × 48 glass button with an icon, as on the scanner's corners.
- ScannerChip
- A chip with the symbology of a code ("QR Code", "GS1-128 · GS1").
- ScannerCloseButton
- A glass button that closes the scanner: by default it pops the current route.
- ScannerController
-
Drives the camera of a
BarcodeScannerand decodes its frames. - ScannerErrorView
- Shown when the camera cannot be used: a card with what happened and the ways forward.
- ScannerFields
- Labelled values in a grid, such as the fields of a boarding pass.
- ScannerGlass
- A translucent panel over the camera: it blurs what is behind it (unless ScannerTheme.blur is off), has a light top edge and a soft shadow.
- ScannerHint
- A glass pill with an optional icon: hints ("Point at a QR code") and titles ("Pay with QR").
- ScannerIcon
- Draws a ScannerIconData.
- ScannerIconData
- A line icon of the scanner widgets, drawn from SVG path data in a 24 × 24 box. The scanner draws its own icons, so it needs no icon font.
- ScannerIcons
- The icons of the scanner widgets.
- ScannerLayout
-
What an overlay needs to know, already in the coordinates of the
BarcodeScannerwidget. - ScannerOverlay
- The default overlay: ScanWindowOverlay and BarcodeOutlines in the ScannerTheme of the scanner.
- ScannerPlaceholder
- Shown while the camera starts: the scan window, its brackets breathing, a spinner and "Starting the camera…", so the layout does not jump when the picture arrives.
- ScannerScope
- Gives the scanner widgets below it a theme and texts.
- ScannerSheet
- A sheet of strong glass at the bottom of the scanner, for results.
- ScannerState
- The camera state of a ScannerController.
- ScannerStrings
-
The texts of the scanner widgets: button labels for screen readers,
states, result sheets. English by default; pass your translations to
BarcodeScanner(strings: ...): - ScannerTemplate
- A ready-made scanner screen: which buttons it has, where the scan window is, what happens when a code is found, and its default theme.
- ScannerTheme
- Colors and shapes of the scanner widgets: the scan window, the buttons, the glass panels and the result sheets.
- ScanVerdict
- The answer of a ScannerCheck: the status and what to tell the user.
- ScanWindow
- The part of the camera preview that is decoded, relative to what the user sees on screen. The default overlay draws exactly this area.
- ScanWindowOverlay
- Dims the camera outside the scan window and draws the window's corner brackets.
- SmartHomeContent
-
A smart home device's setup code: Matter (
MT:…) or HomeKit (X-HM://…), from the label on the device or its box. - SmsContent
-
A text message draft (
sms:,smsto:,mms:,mmsto:). - SpaydPaymentContent
-
A Czech payment (Short Payment Descriptor, SPAYD):
SPD*1.0*ACC:CZ…*AM:480.50*CC:CZK*MSG:…. - SwissAddress
- An address on a Swiss QR-bill.
- SwissQrBillContent
-
A Swiss QR-bill (Swiss Payment Standards, version 2.3):
SPC\n0200\n1\n…. - SwitchCameraButton
- A glass button that switches between the back and the front camera.
- TextContent
- Plain text, or anything not recognised as a more specific type.
- TorchButton
- A glass button that turns the torch on and off; hidden when the camera has no torch.
- UpiPaymentContent
-
An Indian UPI payment:
upi://pay?pa=name@bank&pn=…&am=…. - UrlContent
- A web address.
- VinContent
- A vehicle identification number (ISO 3779): 17 characters, from the Code 39 or Data Matrix on a windshield, door pillar or title.
- VisibleBarcode
- A barcode in view, positioned in the scanner widget.
- WifiContent
-
Wi-Fi network credentials (
WIFI:format). - WifiDppContent
-
A Wi-Fi Easy Connect (DPP) bootstrapping code:
DPP:K:…;;on a router or a smart device, which a phone scans to put the device on its network. - ZoomButtons
- Glass zoom presets; hidden when there are fewer than two. On an iPhone with several cameras on the back they are its cameras: "0.5×" (the ultra-wide camera, ScannerState.minZoom), "1×" and the telephoto camera (ScannerState.telephotoZoom, "4×" on an iPhone 17 Pro). Elsewhere "1×", "2×" and "4×", as far as the camera zooms, after ScannerState.minZoom when it is below 1 (an Android camera that zooms out). A preset selected after pinching shows the actual zoom ("1.6×").
Enums
- AutoZoomState
- Whether the scanner picks the lens and zoom by itself.
- BarcodeContentType
- How the payload of a Barcode should be interpreted.
- BarcodeErrorKind
- The kind of a BarcodeError.
- BarcodeFormat
- A barcode symbology, or a specific variant of one.
- BarcodeThumbnailKind
- How a BarcodeThumbnail pictures a barcode.
- Binarizer
- How an image is turned into black and white before detection.
- CallType
- How a PhoneContent calls.
- CameraFacing
- Which camera to use.
- CameraResolution
- Camera resolution. Higher resolutions read smaller and denser codes but decode each frame more slowly.
- CaptureSource
- Where the barcodes of a BarcodeCapture came from.
- ContactFormat
- How ContactContent.toPayload writes a contact.
- CryptoCurrency
- The network of a CryptoContent.
- DetectionMode
- When a ScannerController reports a barcode.
- EanAddOn
- What to do with EAN-2/EAN-5 add-on symbols (see ReaderOptions.eanAddOn).
- EmvScheme
- The national payment scheme of an EmvPaymentContent, from the globally unique identifier of its merchant account.
- ErrorCorrection
- Error correction level: how much of the symbol can be damaged and still read. Higher levels make the symbol larger.
- FinderShape
- Shape of the finder patterns ("eyes") of a QR code.
- LinkService
- Services with well-known links: messengers, social networks, music, app stores and maps.
- LinkServiceInput
- What LinkService.link takes for a service.
- ModuleShape
- Shape of the data modules of QR, Aztec and Data Matrix codes. Linear barcodes and PDF417 always use plain bars and rows.
- OtpAlgorithm
- The hash function of an OtpContent.
- OtpType
- How an OtpContent counts.
- PixelLayout
- Byte layout of the pixels in a PixelBuffer.
- ScannerButtonShape
- Shape of the scanner's buttons and panels.
- ScannerMode
- What a ScannerTemplate does with the codes it finds.
- ScannerPresentation
- How scanBarcode shows its scanner.
- ScannerStatus
- What a ScannerController is doing.
- ScanStatus
- How a ScannerCheck judged a code.
- SmartHomePlatform
- The smart home standard of a SmartHomeContent.
- SwissReferenceType
- The kind of reference on a Swiss QR-bill.
- TorchState
- Torch availability and state.
- VinRegion
- Where a vehicle was made, from the first character of its VIN.
- WifiSecurity
- Security of a Wi-Fi network.
Extensions
- BarcodeContentOf on Barcode
-
barcode.content: the payload parsed into a typed value. Lives in the content layer, so the core Barcode does not depend on parsing. - BarcodeWriterContent on BarcodeWriter
-
writer.encodeContent(content): encodes a BarcodeContent the way its kind needs. Lives in the content layer, so the core writer does not depend on it.
Constants
- zxingCppVersion → const String
- The zxing-cpp version inside the engine.
Functions
-
scanBarcode(
BuildContext context, {Set< BarcodeFormat> ? formats, ScanWindow? scanWindow, CameraFacing? facing, String? hint, ScannerCheck? check, ScannerPresentation presentation = ScannerPresentation.page, ScannerTemplate? template, ScannerTheme? theme, ScannerStrings? strings}) → Future<Barcode?> -
Opens a scanner and returns the first barcode found (and accepted by
check), ornullif the user closes it. -
warmUpBarcodeEngine(
) → Future< void> -
Starts the barcode engine ahead of time, e.g. in
main(), so that the first scan or read does not wait for it.
Typedefs
-
ScannerActionsBuilder
= List<
ScannerAction> Function(BuildContext context, Barcode barcode, VoidCallback scanAgain) -
Builds the buttons of the default result sheet for
barcode. -
ScannerCheck
= FutureOr<
ScanVerdict?> Function(Barcode barcode) -
Decides whether the scanner accepts
barcode: a ticket at the door, a sign-in code of your own service, a value for a form field. - ScannerOverlayBuilder = Widget Function(BuildContext context, ScannerLayout layout)
- Builds what is drawn over the camera preview.
- ScannerPickCallback = void Function(Barcode barcode, BarcodeCapture capture)
-
Called with the
barcodethe user picked in ScannerMode.pick and thecaptureit came from, which also holds the other codes found with it and gives its picture withcapture.snapshot(barcode). - ScannerResultBuilder = Widget Function(BuildContext context, Barcode barcode, VoidCallback scanAgain)
-
Builds the sheet shown for a scanned
barcode;scanAgainhides it and resumes scanning.
Exceptions / Errors
- BarcodeWriteException
- The data cannot be encoded in the requested format (e.g. letters in an EAN-13, or too much data for the chosen symbol version).
- CameraFailureException
- The camera failed: it is used by another app, or the platform reported an error.
- CameraNotFoundException
- The device has no camera with the requested facing.
- CameraPermissionException
- The user denied camera access (or it is restricted by the system).
- EngineException
- The engine failed to start or stopped unexpectedly. The next call starts it again.
- ImageDecodeException
- The input is not an image the engine can decode (corrupt file, an unsupported format, or not an image at all).
- ScannerException
-
A camera problem reported by the scanner in
ScannerState.error. - ZxingException
- Base class of every exception thrown by flutter_zxing 4.