Added try catch with errorhandling

main
Kai Mannweiler 2023-03-03 18:34:24 +01:00
parent afd5e37ecf
commit c56222660d
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) { void onDetect(capture) {
final List<Barcode> barcodes = capture.barcodes; try {
for (final barcode in barcodes) { final List<Barcode> barcodes = capture.barcodes;
if (barcode.rawValue != null) { for (final barcode in barcodes) {
return handleSucces(barcode.rawValue); if (barcode.rawValue != null) {
return handleSucces(barcode.rawValue);
}
} }
} catch (e) {
handleError();
} }
} }