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,13 +37,29 @@ 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) {
try {
final List<Barcode> barcodes = capture.barcodes;
for (final barcode in barcodes) {
if (barcode.rawValue != null) {
return handleSucces(barcode.rawValue);
}
}
} catch (e) {
handleError();
}
}
@override