/* if you get a blank screen after scanning a QR code and then using Navigator.pop(context, barcode.rawValue) then you might be able to fix the problem by setting the detection speed value to noDuplicates. */ // import packages import 'dart:typed_data'; // needed for Unit8List support import 'package:flutter/material.dart'; import 'package:mobile_scanner/mobile_scanner.dart'; class AddBox extends StatefulWidget { const AddBox({super.key}); @override State<AddBox> createState() => _AddBoxState(); } class _AddBoxState extends State<AddBox> { String barcode_raw_value = 'None'; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Theme.of(context).colorScheme.inversePrimary, title: Text('Add A Box'), ), body: MobileScanner( // fit: BoxFit.contain, controller: MobileScannerController( /// detectionSpeed: DetectionSpeed.normal, detectionSpeed: DetectionSpeed.noDuplicates, facing: CameraFacing.back, torchEnabled: true, ), onDetect: (capture) { final List<Barcode> barcodes = capture.barcodes; final Uint8List? image = capture.image; for (final barcode in barcodes) { debugPrint('Barcode found! ${barcode.rawValue}'); barcode_raw_value = '${barcode.rawValue}'; } Navigator.pop(context, barcode_raw_value); }, ), ); } }