From f5a1273d43418ad745e4cc1253cf033fcc6e857c Mon Sep 17 00:00:00 2001 From: fosse Date: Tue, 8 Aug 2023 11:41:19 -0400 Subject: [PATCH] allow scanning from images --- lib/src/screens/qr/scan_screen.dart | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/src/screens/qr/scan_screen.dart b/lib/src/screens/qr/scan_screen.dart index d65315749..25f3130d6 100644 --- a/lib/src/screens/qr/scan_screen.dart +++ b/lib/src/screens/qr/scan_screen.dart @@ -21,14 +21,14 @@ class ScanScreenState extends State { } Future scanImage() async { - // final ImagePicker imagePicker = ImagePicker(); - // final XFile? file = await imagePicker.pickImage(source: ImageSource.gallery); - // if (file?.path != null) { - // final bool qrCodeFound = await cameraController.analyzeImage(file!.path); - // if (!qrCodeFound && mounted && !popped) { - // UIUtil.showSnackbar(Z.of(context).qrUnknownError, context); - // } - // } + final ImagePicker imagePicker = ImagePicker(); + final XFile? file = await imagePicker.pickImage(source: ImageSource.gallery); + if (file?.path != null) { + final bool qrCodeFound = await cameraController.analyzeImage(file!.path); + if (!qrCodeFound && mounted && !popped) { + throw Exception("No QR code found"); + } + } } @override @@ -123,9 +123,11 @@ class ScanScreenState extends State { builder: (BuildContext context, TorchState state, Widget? child) { switch (state) { case TorchState.off: - return const Icon(Icons.flashlight_off_rounded, color: Colors.white); + return const Icon(Icons.flashlight_off_rounded, + color: Colors.white); case TorchState.on: - return const Icon(Icons.flashlight_on_rounded, color: Colors.yellow); + return const Icon(Icons.flashlight_on_rounded, + color: Colors.yellow); } }, ),