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