diff --git a/lib/widgets/scanner.dart b/lib/widgets/scanner.dart index 46f8c8a..b635d67 100644 --- a/lib/widgets/scanner.dart +++ b/lib/widgets/scanner.dart @@ -37,12 +37,28 @@ class MyScannerState extends State { }); } + void handleError() { + setState(() { + scanning = false; + AwesomeDialog( + context: context, + dialogType: DialogType.error, + title: 'Fehler', + desc: 'Der QR-Code war fehlerhaft!', + ).show(); + }); + } + void onDetect(capture) { - final List barcodes = capture.barcodes; - for (final barcode in barcodes) { - if (barcode.rawValue != null) { - return handleSucces(barcode.rawValue); + try { + final List barcodes = capture.barcodes; + for (final barcode in barcodes) { + if (barcode.rawValue != null) { + return handleSucces(barcode.rawValue); + } } + } catch (e) { + handleError(); } }