Improve error management for label printing (#588)

- Handle empty label
- Handle empty printer
This commit is contained in:
Oliver 2024-12-23 10:36:36 +11:00 committed by GitHub
parent bc44b99d43
commit d84f76d482
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 39 additions and 0 deletions

View file

@ -94,6 +94,28 @@ Future<void> selectAndPrintLabel(
"",
fields,
icon: TablerIcons.printer,
validate: (Map<String, dynamic> data) {
final template = data["label"];
final plugin = data["plugin"];
if (template == null) {
showSnackIcon(
L10().labelSelectTemplate,
success: false,
);
return false;
}
if (plugin == null) {
showSnackIcon(
L10().labelSelectPrinter,
success: false,
);
return false;
}
return true;
},
onSuccess: (Map<String, dynamic> data) async {
int labelId = (data["label"] ?? -1) as int;
var pluginKey = data["plugin"];