Skip to content

Commit cf37871

Browse files
committed
Add returnImage parameter to AiBarcodeScanner
This PR introduces an optional returnImage parameter to the AiBarcodeScanner widget and internally passes it to the MobileScannerController. This enables access to raw frame image data (Uint8List) via BarcodeCapture.image, which is useful for: - Visual frame analysis - Extracting pixel color values - Saving scanned frames Default: false to avoid extra processing for non-image consumers.
1 parent b74f524 commit cf37871

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/src/ai_barcode_scanner.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ class AiBarcodeScanner extends StatefulWidget {
115115
/// Custom icon for the flashlight when off
116116
final IconData flashOffIcon;
117117

118+
/// Whether to return the raw image data (Uint8List) along with the BarcodeCapture.
119+
/// This can be useful for post-scan image processing such as color analysis or saving the frame.
120+
/// Defaults to `false`.
121+
final bool returnImage;
122+
118123
const AiBarcodeScanner({
119124
super.key,
120125
this.fit = BoxFit.cover,
@@ -144,6 +149,7 @@ class AiBarcodeScanner extends StatefulWidget {
144149
this.cameraSwitchIcon = CupertinoIcons.arrow_2_circlepath,
145150
this.flashOnIcon = CupertinoIcons.bolt_fill,
146151
this.flashOffIcon = CupertinoIcons.bolt,
152+
this.returnImage = false,
147153
});
148154

149155
@override
@@ -168,7 +174,10 @@ class _AiBarcodeScannerState extends State<AiBarcodeScanner> {
168174
DeviceOrientation.portraitDown,
169175
]);
170176
}
171-
_controller = widget.controller ?? MobileScannerController();
177+
_controller = widget.controller ?? MobileScannerController(
178+
// Passes the returnImage flag to control whether frame images are returned with barcode data
179+
returnImage: widget.returnImage,
180+
);
172181
}
173182

174183
@override

0 commit comments

Comments
 (0)