mirror of
https://github.com/inventree/inventree-app.git
synced 2025-05-13 20:43:11 +00:00
Don't force barcode data to be a JSON object.
Just send the scanned data to the server, and let it handle it...
This commit is contained in:
parent
d0f1a4d4ce
commit
cd864abfbe
@ -17,20 +17,9 @@ import 'dart:convert';
|
|||||||
|
|
||||||
Future<void> scanQrCode(BuildContext context) async {
|
Future<void> scanQrCode(BuildContext context) async {
|
||||||
|
|
||||||
QrUtils.scanQR.then((String result) {
|
QrUtils.scanQR.then((String barcode) {
|
||||||
|
|
||||||
print("Scanned: $result");
|
print("Scanned: $barcode");
|
||||||
|
|
||||||
Map<String, dynamic> data;
|
|
||||||
|
|
||||||
// Look for JSON data in the result...
|
|
||||||
try {
|
|
||||||
data = json.decode(result);
|
|
||||||
} on FormatException {
|
|
||||||
showErrorDialog(context, "Bad barcode data", result);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
showProgressDialog(context, "Querying Server", "Sending barcode data to server");
|
showProgressDialog(context, "Querying Server", "Sending barcode data to server");
|
||||||
|
|
||||||
@ -39,7 +28,7 @@ Future<void> scanQrCode(BuildContext context) async {
|
|||||||
* It is the responsibility of the server to validate and sanitize the barcode data,
|
* 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.
|
* and return a "common" response that we know how to deal with.
|
||||||
*/
|
*/
|
||||||
InvenTreeAPI().post("barcode/", body: data).then((var response) {
|
InvenTreeAPI().post("barcode/", body: {"barcode": barcode}).then((var response) {
|
||||||
|
|
||||||
// Close the progress dialog
|
// Close the progress dialog
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user