diff --git a/lib/barcode.dart b/lib/barcode.dart index 937abf4b..82e46aeb 100644 --- a/lib/barcode.dart +++ b/lib/barcode.dart @@ -171,88 +171,7 @@ Future scanQrCode(BuildContext context) async { Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeQRView())); return; - /* - print("Scanning"); - String barcode = await FlutterBarcodeScanner.scanBarcode("#F00", "Cancel", false, ScanMode.DEFAULT); - print("and, DONE"); - if (barcode == null || barcode.isEmpty) { - return; - } - print("Scanned: $barcode"); - - showProgressDialog(context, "Querying Server", "Sending barcode data to server"); - */ - - String barcode = null; - /* - * POST the scanned barcode data to the server. - * It is the responsibility of the server to validate and sanitize the barcode data, - * and return a "common" response that we know how to deal with. - */ - InvenTreeAPI().post("barcode/", body: {"barcode": barcode}).then((var response) { - - hideProgressDialog(context); - - if (response.statusCode != 200) { - showDialog( - context: context, - child: new SimpleDialog( - title: Text("Server Error"), - children: [ - ListTile( - title: Text("Error ${response.statusCode}"), - subtitle: Text("${response.body.toString().split("\n").first}"), - ) - ], - ), - ); - - return; - } - - final Map body = json.decode(response.body); - - // TODO - Handle potential error decoding response - - print("Barcode response:"); - print(body.toString()); - - if (body.containsKey('error')) { - showDialog( - context: context, - child: new SimpleDialog( - title: Text("Barcode Error"), - children: [ - ListTile( - title: Text("${body['error']}"), - subtitle: Text("Plugin: ${body['plugin'] ?? ''}"), - ) - ], - ) - ); - } else if (body.containsKey('success')) { - // Decode the barcode! - // Ideally, the server has returned unto us something sensible... - _handleBarcode(context, body); - } else { - showDialog( - context: context, - child: new SimpleDialog( - title: Text("Unknown response"), - children: [ - ListTile( - title: Text("Response data"), - subtitle: Text("${body.toString()}"), - ) - ], - ) - ); - } - - print("body: ${body.toString()}"); - - }); } void _handleBarcode(BuildContext context, Map data) {