ScannerController class

Standalone controller managing hardware camera lifecycle, frame throttling, adaptive frame processing, background isolate execution, ROI cropping, performance metrics telemetry, scan history, auto-zoom, and low-light controls.

Inheritance
Mixed-in types

Constructors

ScannerController({ScanMode initialMode = ScanMode.qr, ResolutionPreset resolutionPreset = cam.ResolutionPreset.high, ScannerOptions options = const ScannerOptions(), dynamic onResultDetected(ScanResult result)?, dynamic onLowLightDetected(bool isLowLight)?, dynamic onStatsUpdated(ScannerStats stats)?, dynamic onFrame(CameraImage frame)?, UniversalScanEngine? scanEngine, ImagePicker? imagePicker})
Constructs a ScannerController.

Properties

activeSession MultiScanSession?
Currently active multi-scan session (null if no session active).
no setter
analytics ScannerAnalytics
Enterprise session telemetry analytics tracker.
final
availableCameras List<CameraDescription>
List of available hardware cameras on device.
no setter
batchResults List<ScanResult>
List of accumulated scan results collected in ScanStrategy.batch mode.
no setter
cameraController → CameraController?
Active camera controller instance, if initialized.
no setter
currentLuminosity double
Ambient frame relative brightness score (0.0 to 1.0).
no setter
currentMode ScanMode
Alias for active scanning mode.
no setter
currentZoomLevel double
Current digital zoom level setting (1.0 to maxZoomLevel).
no setter
documentSession DocumentScanSession?
no setter
errorMessage String?
Last error message encountered during camera or scan operations.
no setter
facing CameraFacing
Hardware camera lens facing direction (mobile_scanner API compatibility).
no setter
fpsState ScannerFpsState
no setter
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
historyController ScanHistoryController
Dedicated scan history controller for recording, searching, and exporting scan results.
latefinal
isBlurry bool
Whether last evaluated frame was blurry.
no setter
isDisposed bool
Whether controller has been disposed.
no setter
isFlashOn bool
Whether flash/torch is currently turned on.
no setter
isFocusLocked bool
Whether autofocus is currently locked.
no setter
isInitialized bool
Whether camera controller and ML engine are initialized and ready.
no setter
isInitializing bool
Whether camera initialization is currently in progress.
no setter
isLowLight bool
Whether camera scene is currently under low ambient lighting.
no setter
isMotionDetected bool
Whether significant camera shaking or motion was detected.
no setter
isPaused bool
Whether live stream processing is currently paused.
no setter
lastResult ScanResult?
Most recently detected ScanResult.
no setter
lastTapFocusPoint Offset?
Most recent tap-to-focus point coordinates.
no setter
maxZoomLevel double
no setter
minZoomLevel double
no setter
motionScore double
Motion magnitude score.
no setter
onFrame → dynamic Function(CameraImage frame)?
Optional callback invoked on each raw live camera image frame for custom ML AI models.
final
onFrameStream Stream<CameraImage>
Stream emitting raw live camera image frames for custom ML AI pipelines.
no setter
onLowLightDetected → dynamic Function(bool isLowLight)?
Optional callback invoked when ambient light changes (low light alert).
final
onLowLightStateChanged Stream<bool>
Stream emitting low light status alerts.
no setter
onResult Stream<ScanResult>
Stream emitting valid detected ScanResult objects.
no setter
onResultDetected → dynamic Function(ScanResult result)?
Optional callback invoked when a valid scan result is detected.
final
onStats Stream<ScannerStats>
Stream emitting real-time performance telemetry.
no setter
onStatsUpdated → dynamic Function(ScannerStats stats)?
Optional callback invoked when internal performance telemetry updates.
final
options ScannerOptions
Configuration options controlling scan strategy, ROI, throttling, and timeouts.
final
resolutionPreset → ResolutionPreset
Active resolution preset setting.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scanHistory List<ScanResult>
In-memory log of recent scan history.
no setter
selectedCameraIndex int
Currently selected camera index in availableCameras.
no setter
selectedMode ScanMode
Currently active scanning mode.
no setter
stats ScannerStats
Current internal telemetry snapshot.
no setter
torchLevel double
Torch intensity brightness setting.
no setter
torchState TorchState
Flashlight torch operation mode (mobile_scanner API compatibility).
no setter

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
analyzeImage(String imagePath, {ScanMode? mode}) Future<ScanResult>
Analyzes an image file from local path (mobile_scanner API compatibility).
autoZoomTo(double targetZoom) Future<void>
Auto-zooms by multiplier when small barcodes are far away.
availableCamerasFunc() Future<List<CameraDescription>>
Exposed for testing dependency injection.
clearBatch() → void
Clears accumulated batch inventory scan list.
clearHistory() → void
Clears in-memory scan history log.
didChangeAccessibilityFeatures() → void
Called when the system changes the set of currently active accessibility features.
inherited
didChangeAppLifecycleState(AppLifecycleState state) → void
Called when the system puts the app in the background or returns the app to the foreground.
override
didChangeLocales(List<Locale>? locales) → void
Called when the system tells the app that the user's locale has changed. For example, if the user changes the system language settings.
inherited
didChangeMetrics() → void
Called when the application's dimensions change. For example, when a phone is rotated.
inherited
didChangePlatformBrightness() → void
Called when the platform brightness changes.
inherited
didChangeTextScaleFactor() → void
Called when the platform's text scale factor changes.
inherited
didChangeViewFocus(ViewFocusEvent event) → void
Called whenever the PlatformDispatcher receives a notification that the focus state on a view has changed.
inherited
didHaveMemoryPressure() → void
Called when the system is running low on memory.
inherited
didPopRoute() Future<bool>
Called when the system tells the app to pop the current route, such as after a system back button press or back gesture.
inherited
didPushRoute(String route) Future<bool>
Called when the host tells the application to push a new route onto the navigator.
inherited
didPushRouteInformation(RouteInformation routeInformation) Future<bool>
Called when the host tells the application to push a new RouteInformation and a restoration state onto the router.
inherited
didRequestAppExit() Future<AppExitResponse>
Called when a request is received from the system to exit the application.
inherited
dispose() → void
Discards any resources used by the object.
override
endSession() SessionStats?
Ends the active multi-scan session.
exportBatchCsv() String
Exports accumulated batch results to CSV string format.
exportBatchJson() String
Exports accumulated batch results to JSON string format.
handleCancelBackGesture() → void
Called when a predictive back gesture is canceled, indicating that no navigation should occur.
inherited
handleCommitBackGesture() → void
Called when a predictive back gesture is finished successfully, indicating that the current route should be popped.
inherited
handleStartBackGesture(PredictiveBackEvent backEvent) bool
Called at the start of a predictive back gesture.
inherited
handleStatusBarTap() → void
Called when the user taps the status bar on iOS, to scroll a scroll view to the top.
inherited
handleUpdateBackGestureProgress(PredictiveBackEvent backEvent) → void
Called when a predictive back gesture moves.
inherited
initialize() Future<void>
Initializes hardware cameras and starts live stream processing with auto-recovery.
inputImageFromBytes(Uint8List bytes, int width, int height, int bytesPerRow) InputImage?
lockFocus() Future<void>
Locks autofocus to current focal plane to prevent continuous hunting.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
pauseScanning() → void
Pauses processing live stream image frames.
pickAndScanImage({ScanMode? mode}) Future<ScanResult?>
Opens gallery image picker and scans selected image file.
pinchZoom(double scale) Future<void>
Performs pinch zoom calculations based on gesture scale factor.
processBytes(Uint8List bytes, {ScanMode? mode, int width = 640, int height = 480}) Future<ScanResult>
Processes raw byte buffer directly from memory.
processImageFile(String imagePath, {ScanMode? mode}) Future<ScanResult>
Processes an image file from a local path.
removeBatchItem(int index) → void
Removes an item from batch scan list by index.
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
resumeScanning() → void
Resumes processing live stream image frames.
scanAll({ScanMode? mode}) Future<List<ScanResult>>
Executes a multi-code batch pass returning all detected ScanResult items in a single scan.
scanAsset(String assetPath, {ScanMode? mode}) Future<ScanResult>
Scans an image loaded from a Flutter asset path.
scanBytes(Uint8List bytes, {ScanMode? mode, int? width, int? height}) Future<ScanResult>
Scans raw byte buffer directly from memory.
scanGallery({ScanMode? mode}) Future<ScanResult?>
Alias for pickAndScanImage for gallery scanning.
scanImage(File imageFile, {ScanMode? mode}) Future<ScanResult>
Scans a local image file directly from a File object.
setAutofocus(bool enabled) Future<void>
Toggles continuous autofocus mode.
setCameraFacing(CameraFacing targetFacing) Future<void>
Switches camera lens facing direction (mobile_scanner API compatibility).
setExposureCompensation(double offset) Future<void>
Sets camera exposure compensation offset.
setExposureOffset(double offset) Future<void>
Sets exposure compensation offset value.
setFlashMode(FlashMode mode) Future<void>
Sets explicit flash mode.
setFocusPoint(Offset point) Future<void>
Sets manual focus point on camera viewport coordinates (0.0 to 1.0).
setMode(ScanMode mode) → void
Sets active scan mode.
setResolution(ResolutionPreset preset) Future<void>
Dynamically changes hardware camera resolution preset.
setTorchBrightness(double level) Future<void>
Sets flashlight torch brightness level.
setTorchLevel(double level) Future<void>
Sets torch level brightness intensity (0.0 to 1.0).
setTorchState(TorchState state) Future<void>
Switches flashlight torch operation state (mobile_scanner API compatibility).
setZoomLevel(double zoom) Future<void>
Sets absolute camera digital zoom level.
setZoomScale(double zoom) Future<void>
Sets camera digital zoom scale (mobile_scanner API compatibility).
start() Future<void>
Starts or resumes scanner operation (mobile_scanner API compatibility).
startDocumentSession({String? name, int? maxPages}) DocumentScanSession
Starts a new multi-page document scanning session (scanbot_sdk style).
startSession({String? name, int? maxItems}) MultiScanSession
Starts a new multi-scan session.
stop() Future<void>
Stops or pauses scanner operation (mobile_scanner API compatibility).
switchCamera() Future<void>
Switches to next available camera.
tapToFocus(Offset relativePoint) Future<void>
Trigger tap-to-focus on camera preview coordinates.
toggleFlash() Future<void>
Toggles camera flash (torch mode / off).
toString() String
A string representation of this object.
inherited
unlockFocus() Future<void>
Unlocks focus to resume continuous autofocus.
warmup() Future<void>
Pre-warms vision engine and hardware resources prior to UI layout assembly.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

prewarm() Future<void>
Global static helper to pre-warm ML Kit engines and camera hardware before UI build.