mirror of
https://github.com/inventree/inventree-app.git
synced 2025-05-02 07:26:50 +00:00
error dialog if the barcode cannot be converted to JSON!
This commit is contained in:
parent
200d2edc9a
commit
d0f1a4d4ce
@ -21,8 +21,16 @@ Future<void> scanQrCode(BuildContext context) async {
|
|||||||
|
|
||||||
print("Scanned: $result");
|
print("Scanned: $result");
|
||||||
|
|
||||||
|
Map<String, dynamic> data;
|
||||||
|
|
||||||
// Look for JSON data in the result...
|
// Look for JSON data in the result...
|
||||||
final data = json.decode(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");
|
||||||
|
|
||||||
|
@ -1,6 +1,25 @@
|
|||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
|
||||||
|
void showErrorDialog(BuildContext context, String title, String description) {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
child: SimpleDialog(
|
||||||
|
title: ListTile(
|
||||||
|
title: Text("Error"),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.exclamationCircle),
|
||||||
|
),
|
||||||
|
children: <Widget>[
|
||||||
|
ListTile(
|
||||||
|
title: Text(title),
|
||||||
|
subtitle: Text(description)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void showProgressDialog(BuildContext context, String title, String description) {
|
void showProgressDialog(BuildContext context, String title, String description) {
|
||||||
showDialog(
|
showDialog(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user