mirror of
				https://github.com/inventree/inventree-app.git
				synced 2025-10-31 05:15:42 +00:00 
			
		
		
		
	Remove old comment
This commit is contained in:
		| @@ -171,88 +171,7 @@ Future<void> 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: <Widget>[ | ||||
|             ListTile( | ||||
|               title: Text("Error ${response.statusCode}"), | ||||
|               subtitle: Text("${response.body.toString().split("\n").first}"), | ||||
|             ) | ||||
|           ], | ||||
|         ), | ||||
|       ); | ||||
|  | ||||
|       return; | ||||
|     } | ||||
|  | ||||
|     final Map<String, dynamic> 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: <Widget>[ | ||||
|             ListTile( | ||||
|               title: Text("${body['error']}"), | ||||
|               subtitle: Text("Plugin: ${body['plugin'] ?? '<no plugin information>'}"), | ||||
|             ) | ||||
|           ], | ||||
|         ) | ||||
|       ); | ||||
|     } 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: <Widget>[ | ||||
|             ListTile( | ||||
|               title: Text("Response data"), | ||||
|               subtitle: Text("${body.toString()}"), | ||||
|             ) | ||||
|           ], | ||||
|         ) | ||||
|       ); | ||||
|     } | ||||
|  | ||||
|     print("body: ${body.toString()}"); | ||||
|  | ||||
|   }); | ||||
| } | ||||
|  | ||||
| void _handleBarcode(BuildContext context, Map<String, dynamic> data) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user