mirror of
https://github.com/inventree/inventree-app.git
synced 2025-07-30 17:21:28 +00:00
Cleanup for API error handling
Ref: https://stackoverflow.com/questions/54617432/looking-up-a-deactivated-widgets-ancestor-is-unsafe
This commit is contained in:
@@ -66,14 +66,11 @@ class BarcodeHandler {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> processBarcode(BuildContext context, QRViewController _controller, String barcode, {String url = "barcode/", bool show_dialog = false}) {
|
||||
Future<void> processBarcode(BuildContext context, QRViewController _controller, String barcode, {String url = "barcode/"}) {
|
||||
this._context = context;
|
||||
this._controller = _controller;
|
||||
|
||||
print("Scanned barcode data: ${barcode}");
|
||||
if (show_dialog) {
|
||||
showProgressDialog(context, "Scanning", "Sending barcode data to server");
|
||||
}
|
||||
|
||||
// Send barcode request to server
|
||||
InvenTreeAPI().post(
|
||||
@@ -83,10 +80,6 @@ class BarcodeHandler {
|
||||
}
|
||||
).then((var response) {
|
||||
|
||||
if (show_dialog) {
|
||||
hideProgressDialog(context);
|
||||
}
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
showErrorDialog(
|
||||
context,
|
||||
@@ -119,10 +112,6 @@ class BarcodeHandler {
|
||||
Duration(seconds: 5)
|
||||
).catchError((error) {
|
||||
|
||||
if (show_dialog) {
|
||||
hideProgressDialog(context);
|
||||
}
|
||||
|
||||
showErrorDialog(
|
||||
context,
|
||||
"Error",
|
||||
|
Reference in New Issue
Block a user