Added try catch with errorhandling
parent
afd5e37ecf
commit
c56222660d
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue