Merge branch '20-todo-fehlerhafte-andere-qr-codes-abfangen' into 'main'

Added try catch with errorhandling

Closes #20

See merge request Crondung/hsma_cpd!26
main
Julian Gegner 2023-03-04 08:40:27 +00:00
commit f5fe8eea5a
1 changed files with 20 additions and 4 deletions

View File

@ -37,12 +37,28 @@ class MyScannerState extends State<MyScanner> {
});
}
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<Barcode> barcodes = capture.barcodes;
for (final barcode in barcodes) {
if (barcode.rawValue != null) {
return handleSucces(barcode.rawValue);
try {
final List<Barcode> barcodes = capture.barcodes;
for (final barcode in barcodes) {
if (barcode.rawValue != null) {
return handleSucces(barcode.rawValue);
}
}
} catch (e) {
handleError();
}
}