import 'package:barcode_scan2/barcode_scan2.dart'; var isQrScannerShown = false; Future presentQRScanner() async { isQrScannerShown = true; try { final result = await BarcodeScanner.scan(); isQrScannerShown = false; return result.rawContent.trim(); } catch (e) { isQrScannerShown = false; rethrow; } }