2

I’m getting random barcode values when the scanner view closes due to timeout even though no QR code or barcode in front of the camera.

Each time this happens, the detected values are different.

Code :

class _QrCodeScannerScreenState extends State<QrCodeScannerScreen> {
 late MobileScannerController _cameraController;
 @override
 void initState() {
 _cameraController = MobileScannerController();
 super.initState();
 }
 @override
 void dispose() {
 _cameraController.dispose();
 super.dispose();
 }
 @override
 Widget build(BuildContext context) {
 final scrWidth = context.mediaQueryWidth;
 final scrHeight = context.mediaQueryHeight;
 return Scaffold(
 body: Stack(
 alignment: Alignment.topCenter,
 children: [
 Positioned(
 child: SizedBox(
 height: scrHeight,
 width: scrWidth,
 child: MobileScanner(
 fit: BoxFit.contain,
 errorBuilder: (p0, p1) => const SizedBox(),
 controller: _cameraController,
 onDetect: (capture) async {
 log("${capture.barcodes.first.rawValue}first value");
 for (final val in capture.barcodes) {
 log(
 val.rawValue ??
 "",
 );
 }
 log("${capture.raw} Raw value");
 },
 ),
 ),
 ),
 ],
 ),
 );
 }
}

Output :

[log] 7181710678871first value
[log] 7181710678871
[log] {name: barcode, data: [{calendarEvent: null, contactInfo: null, corners: [{x: 608.0, y: 1363.0}, {x: 611.0, y: 1369.0}, {x: 299.0, y: 1468.0}, {x: 297.0, y: 1462.0}], displayValue: 7181710678871, driverLicense: null, email: null, format: 32, geoPoint: null, phone: null, rawBytes: [55, 49, 56, 49, 55, 49, 48, 54, 55, 56, 56, 55, 49], rawValue: 7181710678871, size: {width: 314.0, height: 105.0}, sms: null, type: 5, url: null, wifi: null}], image: {bytes: null, width: 1440.0, height: 1920.0}} Raw value

version : mobile_scanner: ^7.1.3

asked Nov 3, 2025 at 6:58
3
  • is errorBuilder called (in case of any error)? Commented Nov 3, 2025 at 7:36
  • @pskink There’s no error occurring. Commented Nov 3, 2025 at 7:56
  • Maybe due to camera frame noise/pixelation? Commented Nov 4, 2025 at 14:47

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.