AiBarcodeScanner class
The main barcode scanner widget.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- AiBarcodeScanner
Constructors
-
AiBarcodeScanner({Key? key, BoxFit fit = BoxFit.cover, MobileScannerController? controller, double scanWindowUpdateThreshold = 0.0, Widget overlayBuilder(BuildContext, BoxConstraints, MobileScannerController, bool?)?, Widget errorBuilder(BuildContext, MobileScannerException)?, void onDetectError(Object, StackTrace)?, bool useAppLifecycleState = true, Widget placeholderBuilder(BuildContext)?, void onDispose()?, Rect? scanWindow, PreferredSizeWidget? appBarBuilder(BuildContext context, MobileScannerController controller)?, void onDetect(BarcodeCapture)?, bool validator(BarcodeCapture)?, void onImagePick(String?)?, GalleryButtonType galleryButtonType = GalleryButtonType.filled, Widget? bottomSheetBuilder(BuildContext context, MobileScannerController controller)?, bool extendBodyBehindAppBar = true, AlignmentGeometry? galleryButtonAlignment, List<
Widget> ? actions, bool setPortraitOrientation = true, ScannerOverlayConfig overlayConfig = const ScannerOverlayConfig(), String galleryButtonText = 'Upload from gallery', IconData galleryIcon = CupertinoIcons.photo, IconData cameraSwitchIcon = CupertinoIcons.arrow_2_circlepath, IconData flashOnIcon = CupertinoIcons.bolt_fill, IconData flashOffIcon = CupertinoIcons.bolt, bool returnImage = false, Future<void> onCustomImagePicker(bool validator(BarcodeCapture)?, void onDetect(BarcodeCapture)?, MobileScannerController controller)?, Widget? child}) -
const
Properties
-
actions
→ List<
Widget> ? -
A list of additional actions to be added to the
AppBar.final - appBarBuilder → PreferredSizeWidget? Function(BuildContext context, MobileScannerController controller)?
-
A builder for the
AppBarof the scanner screen.final -
A builder for the bottom navigation bar of the scanner screen.
final
- bottomSheetBuilder → Widget? Function(BuildContext context, MobileScannerController controller)?
-
A builder for a bottom sheet that is displayed below the camera preview.
final
- cameraSwitchIcon → IconData
-
Custom icon for the camera switch button
final
- child → Widget?
-
for custom child any where in the body.
This will override the gallery button for filled.
use
Align/Positionedto position the child.final - controller → MobileScannerController?
-
The controller for the mobile scanner.
final
- errorBuilder → Widget Function(BuildContext, MobileScannerException)?
-
A builder for displaying an error widget when the scanner fails to start.
If null, a default error widget is used.
final
- extendBodyBehindAppBar → bool
-
Whether the body of the scaffold should extend behind the app bar. Defaults to
true.final - fit → BoxFit
-
Defines how the camera preview will be fitted into the layout.
final
- flashOffIcon → IconData
-
Custom icon for the flashlight when off
final
- flashOnIcon → IconData
-
Custom icon for the flashlight when on
final
- galleryButtonAlignment → AlignmentGeometry?
-
The alignment of the gallery button.
final
- galleryButtonText → String
-
The text to display on the gallery button.
final
- galleryButtonType → GalleryButtonType
-
The type of gallery button to use.
final
- galleryIcon → IconData
-
Custom icon for the gallery button
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
onCustomImagePicker
→ Future<
void> Function(bool validator(BarcodeCapture)?, void onDetect(BarcodeCapture)?, MobileScannerController controller)? -
for custom image picker function.
final
- onDetect → void Function(BarcodeCapture)?
-
The primary callback function that is called when a barcode is detected.
final
- onDetectError → void Function(Object, StackTrace)?
-
A callback function that is called when an error occurs during barcode detection.
final
- onDispose → void Function()?
-
A callback function that is called when the widget is disposed.
final
- onImagePick → void Function(String?)?
-
A callback function that is called when an image is picked from the gallery.
Returns the path of the picked image.
final
- overlayBuilder → Widget Function(BuildContext, BoxConstraints, MobileScannerController, bool?)?
-
A builder for a custom overlay that can be placed on top of the scanner.
This will override the default custom overlay.
final
- overlayConfig → ScannerOverlayConfig
-
Configuration for the scanner overlay (lines, borders, colors).
final
- placeholderBuilder → Widget Function(BuildContext)?
-
A builder for a placeholder widget that is displayed while the camera is initializing.
If null, a black
ColoredBoxis used.final - returnImage → bool
-
Whether to return the raw image data (Uint8List) along with the BarcodeCapture.
This can be useful for post-scan image processing such as color analysis or saving the frame.
Defaults to
false.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scanWindow → Rect?
-
The rectangular area on the screen where the scanner will focus on detecting barcodes.
If null, a default window will be used.
REFACTORED: This is now the single source of truth for the scan window dimensions.
final
- scanWindowUpdateThreshold → double
-
The threshold for updates to the scanWindow.
final
- setPortraitOrientation → bool
-
Locks the screen orientation to portrait mode. Defaults to
true.final - useAppLifecycleState → bool
-
Whether to use the app lifecycle state to pause the camera when the app is paused.
final
- validator → bool Function(BarcodeCapture)?
-
A function that validates a detected barcode.
Returns
trueif the barcode is valid,falseotherwise.final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< AiBarcodeScanner> -
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, int wrapWidth = 65}) → 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