you can close scan page by adding this line to your code
if (barcodeScanRes != null){ print(barcodeScanRes); // this will send your scan result to previous page // or you can navigate to other page after scan success Navigator.pop(context, barcodeScanRes); }
String barcodeScanRes; // put this variable in statefull widget Future<void> scanQR() async { try { barcodeScanRes = await FlutterBarcodeScanner.scanBarcode( '#ff6666', 'Cancel', true, ScanMode.QR); // add this line to close scanner or naivigate to other page if (barcodeScanRes != null){ print(barcodeScanRes); Navigator.pop(context, barcodeScanRes); } } on PlatformException { barcodeScanRes = 'Failed to get platform version.'; } if (!mounted) return; setState(() { _scanBarcode = barcodeScanRes; }); }
or if you want to pause the camera after scan, you can use this package https://pub.dev/packages/qr_code_scanner