From cffae11df4ba64bbcbc122d70df0428ccdd7d62c Mon Sep 17 00:00:00 2001 From: problematicconsumer Date: Sat, 6 Jan 2024 13:36:40 +0330 Subject: [PATCH] Fix qr scanner links --- CHANGELOG.md | 1 + lib/features/common/qr_code_scanner_screen.dart | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7294baf6c..e78c0e90d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ ### Bug Fixes - Fixed Android service mode +- Fixed QR code scanner not scanning deep links ## [0.13.4.dev] - 2023-1-4 diff --git a/lib/features/common/qr_code_scanner_screen.dart b/lib/features/common/qr_code_scanner_screen.dart index 152df8a0d..4199bb041 100644 --- a/lib/features/common/qr_code_scanner_screen.dart +++ b/lib/features/common/qr_code_scanner_screen.dart @@ -77,11 +77,17 @@ class QRCodeScannerScreen extends HookConsumerWidget with PresLogger { MobileScanner( controller: controller, onDetect: (capture) { - final data = capture.barcodes.first; - if (context.mounted && data.type == BarcodeType.url) { - loggy.debug('captured raw: [${data.rawValue}]'); - loggy.debug('captured url: [${data.url?.url}]'); - Navigator.of(context, rootNavigator: true).pop(data.url?.url); + final rawData = capture.barcodes.first.rawValue; + loggy.debug('captured raw: [$rawData]'); + if (rawData != null) { + final uri = Uri.tryParse(rawData); + if (context.mounted && uri != null) { + loggy.debug('captured url: [$uri]'); + Navigator.of(context, rootNavigator: true) + .pop(uri.toString()); + } + } else { + loggy.warning("unable to capture"); } }, errorBuilder: (_, error, __) {