fix(client): 打印异常加 try-catch,错误以 SnackBar 提示用户

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-05-25 20:41:15 +08:00
parent 93878511e5
commit 44ffedb56a
3 changed files with 57 additions and 9 deletions
+15 -3
View File
@@ -189,7 +189,11 @@ Future<void> printProductLabelImpl({
),
));
await Printing.layoutPdf(onLayout: (_) async => doc.save());
try {
await Printing.layoutPdf(onLayout: (_) async => doc.save());
} catch (e) {
throw Exception('打印失败,请检查打印机连接和驱动是否正常。\n详情:$e');
}
}
pw.Widget _label2ColRow(
@@ -424,7 +428,11 @@ Future<void> printStockInOrderImpl(StockInOrder order) async {
),
],
));
await Printing.layoutPdf(onLayout: (_) async => doc.save());
try {
await Printing.layoutPdf(onLayout: (_) async => doc.save());
} catch (e) {
throw Exception('打印失败,请检查打印机连接和驱动是否正常。\n详情:$e');
}
}
Future<void> printStockOutOrderImpl(StockOutOrder order) async {
@@ -474,5 +482,9 @@ Future<void> printStockOutOrderImpl(StockOutOrder order) async {
),
],
));
await Printing.layoutPdf(onLayout: (_) async => doc.save());
try {
await Printing.layoutPdf(onLayout: (_) async => doc.save());
} catch (e) {
throw Exception('打印失败,请检查打印机连接和驱动是否正常。\n详情:$e');
}
}