mmm
This commit is contained in:
@@ -17,21 +17,31 @@ class TicketPdfService {
|
||||
final font = await PdfGoogleFonts.robotoRegular();
|
||||
final boldFont = await PdfGoogleFonts.robotoBold();
|
||||
|
||||
pdf.addPage(
|
||||
pw.Page(
|
||||
pageFormat: PdfPageFormat.a4,
|
||||
margin: const pw.EdgeInsets.all(20),
|
||||
build: (context) {
|
||||
return pw.Column(
|
||||
children: [
|
||||
// 1. METÀ SUPERIORE: CLIENTE
|
||||
_buildTicketHalf(
|
||||
pw.Widget customerHalf = await _buildTicketHalf(
|
||||
ticket,
|
||||
company,
|
||||
font,
|
||||
boldFont,
|
||||
isForCustomer: true,
|
||||
),
|
||||
);
|
||||
|
||||
pw.Widget storeHalf = await _buildTicketHalf(
|
||||
ticket,
|
||||
company,
|
||||
font,
|
||||
boldFont,
|
||||
isForCustomer: false,
|
||||
);
|
||||
|
||||
pdf.addPage(
|
||||
pw.Page(
|
||||
pageFormat: PdfPageFormat.a4,
|
||||
margin: const pw.EdgeInsets.all(20),
|
||||
build: (pw.Context context) {
|
||||
return pw.Column(
|
||||
children: [
|
||||
// 1. METÀ SUPERIORE: CLIENTE
|
||||
customerHalf,
|
||||
|
||||
pw.SizedBox(height: 10),
|
||||
|
||||
@@ -47,32 +57,26 @@ class TicketPdfService {
|
||||
pw.SizedBox(height: 10),
|
||||
|
||||
// 2. METÀ INFERIORE: NEGOZIO
|
||||
_buildTicketHalf(
|
||||
ticket,
|
||||
company,
|
||||
font,
|
||||
boldFont,
|
||||
isForCustomer: false,
|
||||
),
|
||||
storeHalf,
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
await Printing.layoutPdf(
|
||||
onLayout: (PdfPageFormat format) async => pdf.save(),
|
||||
);
|
||||
final savedPdf = await pdf.save();
|
||||
|
||||
await Printing.layoutPdf(onLayout: (PdfPageFormat format) => savedPdf);
|
||||
}
|
||||
|
||||
/// Helper per costruire una singola metà (Cliente o Negozio)
|
||||
pw.Widget _buildTicketHalf(
|
||||
Future<pw.Widget> _buildTicketHalf(
|
||||
TicketModel ticket,
|
||||
CompanyModel company,
|
||||
pw.Font font,
|
||||
pw.Font boldFont, {
|
||||
required bool isForCustomer,
|
||||
}) {
|
||||
}) async {
|
||||
return pw.Expanded(
|
||||
//height: 380, // Circa metà A4 meno i margini
|
||||
child: pw.Column(
|
||||
|
||||
@@ -33,7 +33,7 @@ dependencies:
|
||||
uuid: ^4.5.3
|
||||
pdf: ^3.12.0
|
||||
universal_io: ^2.3.1
|
||||
printing: ^5.14.3
|
||||
printing: ^5.13.1
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
Reference in New Issue
Block a user