CodeScanner class
Code Scanner
A flexible code scanner for QR codes, barcodes and many others. Using Google's ML Kit. Use it as a Widget with a camera or use the methods provided, with a camera controller..
Features
- Scan Linear and 2D formats: QR Code, Barcode, ...
- Widget with integrated camera
- Listen for callbacks with every code scanned
- Choose which formats to scan
- Overlay the camera preview with a custom view
- Camera lifecycle
Scannable Formats
- Aztec
- Codabar
- Code 39
- Code 93
- Code 128
- Data Matrix
- EAN-8
- EAN-13
- ITF
- PDF417
- QR Code
- UPC-A
- UPC-E
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- CodeScanner
Constructors
-
CodeScanner({Key? key, CameraController? controller, CameraLensDirection direction = CameraLensDirection.back, ResolutionPreset resolution = ResolutionPreset.high, List<
BarcodeFormat> formats = const [BarcodeFormat.all], Duration scanInterval = const Duration(seconds: 1), bool once = false, double? aspectRatio, void onCreated(CameraController controller)?, void onScan(String? code, Barcode details, CodeScannerCameraListener listener)?, void onScanAll(List<Barcode> barcodes, CodeScannerCameraListener listener)?, bool? onAccessDenied(CameraException error, CameraController controller)?, void onError(Object error, CodeScannerCameraListener listener)?, Widget? loading, Widget? overlay}) -
Code Scanner
const
Properties
- aspectRatio → double?
-
final
- controller → CameraController?
-
final
- direction → CameraLensDirection
-
Which camera to use:
final
-
formats
→ List<
BarcodeFormat> -
List of the scannable formats:
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- loading → Widget?
-
Widget to show before the cameras are initialized.
final
- onAccessDenied → (bool? Function(CameraException error, CameraController controller)?)
-
Called whenever camera access permission is denied by the user.
final
- once → bool
-
Whether or not, when a code is scanned, the controller should close and no longer scan.
final
- onCreated → (void Function(CameraController controller)?)
-
Called whenever a controller is created.
final
- onError → (void Function(Object error, CodeScannerCameraListener listener)?)
-
final
- onScan → (void Function(String? code, Barcode details, CodeScannerCameraListener listener)?)
-
final
-
onScanAll
→ (void Function(List<
Barcode> barcodes, CodeScannerCameraListener listener)?) -
final
- overlay → Widget?
-
Widget to overlay on top of the camera.
final
- resolution → ResolutionPreset
-
Quality of the camera:
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scanInterval → Duration
-
Duration of delay between scans, to prevent lag.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< CodeScanner> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of
DiagnosticsNode
objects describing this node's children.inherited -
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited