Specialized Inputs
1. Requirements Document
Overview
Hardware-integrated input components for capturing data from the physical world, such as QR codes, Barcodes, and NFC tags.
User Stories
- As a Warehouse Manager, I want to scan a product barcode to auto-fill its ID.
- As an Event Organizer, I want to scan QR tickets to validate entry.
- As a Developer, I want to easily toggle the camera flash/torch during scanning.
Functional Requirements
- Scanning:
- Fast recognition of common formats (QR, EAN-13, UPC).
- Customizable scan area (Overlay).
- Hardware Control:
- Camera switching (Front/Back).
- Torch Toggle.
- Permissions:
- Gracefully handle camera permission denial with custom UI.
2. Technical Document
Architecture
System Architecture
Specialized inputs require deep hardware integration. The Camera Controller establishes the data stream, while the Decoder Engine processes frames in a background isolate to ensure the main UI thread remains responsive (60fps).
API Design
Scanner Configuration
class ScannerConfig {
final List<BarcodeFormat> formats; // [qr, ean13]
final bool showOverlay;
final bool startEnabled;
const ScannerConfig({
this.formats = const [BarcodeFormat.qr],
this.showOverlay = true,
this.startEnabled = true
});
}Internal Logic
- Decoder: Runs in a background isolate to prevent UI jank during image processing.
- LifeCycle: Automatically pauses camera stream when app goes to background (
didChangeAppLifecycleState).