BarcodeScannerWithSearch class
A barcode scanner widget with an expandable side action area.
DEPRECATED: Use BarcodeScannerWidget with enableActionButtons and
actionButtons parameters instead for a more flexible and unified API.
This widget combines the camera-based barcode scanner with a configurable side action area. When the side action is tapped, the camera pauses and the action area expands. When the camera mode button is tapped, the camera resumes and the action area collapses.
Example usage (deprecated):
BarcodeScannerWithSearch(
onBarcodeDetected: (barcode) => print('Scanned: $barcode'),
sideActionConfig: BarcodeSideActionConfig.search(
onTap: () => print('Search tapped'),
title: 'Tap to search',
triggerSearchImmediately: true,
),
)
Migration: Use the unified BarcodeScannerWidget instead:
BarcodeScannerWidget(
onBarcodeDetected: (barcode) => print('Scanned: $barcode'),
enableActionButtons: true,
actionButtons: [
BarcodeScannerActionButton.search(
onTap: () => print('Search tapped'),
title: 'Tap to search',
triggerImmediately: true,
),
],
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- BarcodeScannerWithSearch
- Annotations
-
- @Deprecated('Use BarcodeScannerWidget with enableActionButtons and actionButtons instead')
Constructors
-
BarcodeScannerWithSearch({Key? key, required dynamic onBarcodeDetected(String), required BarcodeSideActionConfig sideActionConfig, BarcodeScannerConfig config = const BarcodeScannerConfig(), VoidCallback? onPermissionDenied, Widget? permissionDeniedWidget, Color? lineColor, Color? cooldownLineColor, Color? outOfFocusLineColor, double height = 180.0, double? minHeight, double? maxHeight, ValueChanged<
BarcodeScannerMode> ? onModeChanged, BarcodeScannerMode initialMode = BarcodeScannerMode.camera, double spacing = 8.0, bool attachSideActionToCamera = true, Color? cameraModeActiveBackgroundColor, Color? cameraModeActiveIconColor, Color? cameraModeInactiveBackgroundColor, Color? cameraModeInactiveIconColor, @Deprecated('Use cameraModeInactiveBackgroundColor instead') Color? cameraModeBackgroundColor, @Deprecated('Use cameraModeInactiveIconColor instead') Color? cameraModeIconColor, double? zoomAreaIdleOpacity, double? zoomAreaActiveOpacity, int? zoomAreaOpacityTimeoutSeconds}) -
const
Properties
- attachSideActionToCamera → bool
-
Whether to attach the side action button directly to the camera area (no spacing).
When true, the side action button's left corners will be square to align with the camera.
Defaults to true for visual continuity between camera and button.
final
- cameraModeActiveBackgroundColor → Color?
-
Background color for the camera mode button when camera is active.
final
- cameraModeActiveIconColor → Color?
-
Icon color for the camera mode button when camera is active.
final
- cameraModeBackgroundColor → Color?
-
@Deprecated Use cameraModeInactiveBackgroundColor instead.
final
- cameraModeIconColor → Color?
-
@Deprecated Use cameraModeInactiveIconColor instead.
final
- cameraModeInactiveBackgroundColor → Color?
-
Background color for the camera mode button when in search mode (inactive).
final
- cameraModeInactiveIconColor → Color?
-
Icon color for the camera mode button when in search mode (inactive).
final
- config → BarcodeScannerConfig
-
Configuration for the barcode scanner.
final
- cooldownLineColor → Color?
-
Custom color for the scanning line when in cooldown.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → double
-
The height of the scanner container.
When using minHeight and maxHeight, this value is used as the initial/preferred height.
final
- initialMode → BarcodeScannerMode
-
Initial mode of the scanner.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- lineColor → Color?
-
Custom color for the scanning line.
final
- maxHeight → double?
-
The maximum height constraint for the camera area.
When set, the widget will use ConstrainedBox with this maximum height.
final
- minHeight → double?
-
The minimum height constraint for the camera area.
When set, the widget will use ConstrainedBox with this minimum height.
final
- onBarcodeDetected → dynamic Function(String)
-
Callback triggered when a barcode is successfully detected.
final
-
onModeChanged
→ ValueChanged<
BarcodeScannerMode> ? -
Callback when the mode changes.
final
- onPermissionDenied → VoidCallback?
-
Optional callback for permission denied state.
final
- outOfFocusLineColor → Color?
-
Custom color for the scanning line when barcode is out of focus area.
final
- permissionDeniedWidget → Widget?
-
Custom widget to display when permission is not granted.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sideActionConfig → BarcodeSideActionConfig
-
Configuration for the side action area.
final
- spacing → double
-
The spacing between camera and side action area.
Note: This spacing is only applied between the camera mode button and side action area in search mode.
In camera mode, the side action button is attached directly to the camera area for visual continuity.
final
- zoomAreaActiveOpacity → double?
-
The opacity of the zoom control area when active (user interacting).
Value should be between 0.0 (fully transparent) and 1.0 (fully opaque).
If null, uses the value from BarcodeScannerConfig.zoomAreaActiveOpacity.
final
- zoomAreaIdleOpacity → double?
-
The opacity of the zoom control area when idle (not interacting).
Value should be between 0.0 (fully transparent) and 1.0 (fully opaque).
If null, uses the value from BarcodeScannerConfig.zoomAreaIdleOpacity.
final
- zoomAreaOpacityTimeoutSeconds → int?
-
Duration in seconds after which the zoom area returns to idle opacity.
If null, uses the value from BarcodeScannerConfig.zoomAreaOpacityTimeoutSeconds.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< BarcodeScannerWithSearch> -
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