32 Widget
build(BuildContext context) {
35 padding: EdgeInsets.only(top: 2.sp),
36 decoration: BoxDecoration(
37 color: Theme.of(context).colorScheme.primary,
38 borderRadius: BorderRadius.circular(20),
41 padding: EdgeInsets.symmetric(horizontal: 15.sp, vertical: 15.sp),
42 child: SingleChildScrollView(
44 mainAxisSize: MainAxisSize.min,
45 crossAxisAlignment: CrossAxisAlignment.start,
48 width: MediaQuery.of(context).size.width,
50 EdgeInsets.symmetric(vertical: 16.sp, horizontal: 25.sp),
51 decoration: BoxDecoration(
52 borderRadius: BorderRadius.circular(200.sp),
53 gradient: LinearGradient(
55 Theme.of(context).colorScheme.surface.withOpacity(0.11),
56 Theme.of(context).colorScheme.primary.withOpacity(0.11),
61 mainAxisAlignment: MainAxisAlignment.spaceBetween,
65 'assets/svgs/logo_aidra.svg',
67 colorFilter: ColorFilter.mode(
68 Theme.of(context).colorScheme.primary,
76 SizedBox(height: 20.sp),
82 size: MainAxisSize.max,
84 icon: HugeIcons.strokeRoundedBinaryCode,
91 icon: HugeIcons.strokeRoundedCalendar01,
95 ? DateFormat(
'yyyy-MM-dd')
102 icon: HugeIcons.strokeRoundedWeightScale01,
112 SizedBox(height: 15.sp),
115 icon: HugeIcons.strokeRoundedEqualSignCircle,
119 SizedBox(height: 15.sp),
120 Divider(height: 0.0),
121 SizedBox(height: 5.sp),
123 padding: EdgeInsets.symmetric(horizontal: 15.sp),
125 mainAxisAlignment: MainAxisAlignment.spaceBetween,
130 HugeIcons.strokeRoundedCoins01,
131 color: Theme.of(context).colorScheme.primary,
133 SizedBox(height: 13.sp),
135 NumberFormat.currency(
138 collection.orderLines?.first.priceTotal ?? 0),
139 textAlign: TextAlign.center,
141 SizedBox(height: 5.sp),
145 textAlign: TextAlign.center,
147 Theme.of(context).textTheme.bodySmall?.copyWith(
149 color: Theme.of(context).hintColor,
158 received:
collection.orderLines?.first.qtyReceived ?? 0,
159 qty:
collection.orderLines?.first.productQty ?? 0,
164 SizedBox(height: 5.sp),
165 Divider(height: 0.0),
166 SizedBox(height: 15.sp),
169 width: MediaQuery.of(context).size.width,
170 child: ElevatedButton(
171 style: ElevatedButton.styleFrom(
173 foregroundColor: Theme.of(context).colorScheme.primary,
178 shape: RoundedRectangleBorder(
179 borderRadius: BorderRadius.circular(200),
181 color: Theme.of(context).colorScheme.primary,
187 mainAxisAlignment: MainAxisAlignment.center,
189 Icon(HugeIcons.strokeRoundedDownload05),
190 SizedBox(width: 5.sp),
194 style: Theme.of(context)
198 color: Theme.of(context).colorScheme.primary,
204 generateCollectionVoucher(collection.name ??
'', context);
260 required BuildContext context,
262 required String
label,
263 required String? info,
267 padding: EdgeInsets.symmetric(horizontal: 7.sp),
269 mainAxisSize: size ?? MainAxisSize.min,
274 decoration: BoxDecoration(
276 Theme.of(context).colorScheme.primary.withOpacity(0.11),
277 borderRadius: BorderRadius.circular(10),
282 color: Theme.of(context).colorScheme.primary,
286 SizedBox(width: 15.sp),
288 mainAxisSize: MainAxisSize.min,
289 crossAxisAlignment: CrossAxisAlignment.start,
295 style: Theme.of(context).textTheme.bodySmall,
298 SizedBox(height: 3.sp),
302 style: Theme.of(context).textTheme.bodySmall,
313 required String
label,
314 required BuildContext context,
315 required num received,
319 double percentageValue = (qty > 0) ? (received / qty) : 0.0;
320 percentageValue = percentageValue > 1.0 ? 1.0 : percentageValue;
323 padding: EdgeInsets.all(10.sp),
324 decoration: BoxDecoration(
325 borderRadius: BorderRadius.circular(10),
328 crossAxisAlignment: CrossAxisAlignment.center,
330 CircularPercentIndicator(
333 percent: percentageValue,
335 '${(percentageValue * 100).toStringAsFixed(0)}%',
336 style: Theme.of(context).textTheme.bodySmall?.copyWith(
342 Theme.of(context).colorScheme.primary.withOpacity(0.11),
344 SizedBox(height: 10.sp),
347 textAlign: TextAlign.center,
348 style: Theme.of(context).textTheme.bodySmall?.copyWith(
350 color: Theme.of(context).hintColor,
361 final pdf = pw.Document();
363 final qrCode = pw.BarcodeWidget(
364 barcode: pw.Barcode.qrCode(),
370 final directorSignature = pw.Column(
373 'Driver / Collector : Ali Iftikar',
385 fit: pw.BoxFit.contain,
391 final collectorSignature = pw.Column(
394 'Collection Point : Shah waqar',
406 fit: pw.BoxFit.contain,
417 crossAxisAlignment: pw.CrossAxisAlignment.center,
420 'Collection Voucher',
422 pw.SizedBox(height: 8),
424 'Document Number : ${collection.name}',
426 fontSize: 24, fontWeight: pw.FontWeight.normal),
428 pw.SizedBox(height: 30),
430 crossAxisAlignment: pw.CrossAxisAlignment.start,
433 'Name: Buffalo Wings & Rings - DIFC',
435 fontSize: 20, fontWeight: pw.FontWeight.normal),
437 pw.SizedBox(height: 8),
439 'Address: Liberty House - Level C - Al Sukouk Street - DIFC Dubai, United Arab Emirates',
441 fontSize: 20, fontWeight: pw.FontWeight.normal),
445 pw.SizedBox(height: 30),
447 border: pw.TableBorder.all(),
452 padding: const pw.EdgeInsets.all(8),
458 padding: const pw.EdgeInsets.all(8),
459 child: pw.Text(
'9/12/2024'),
462 padding: const pw.EdgeInsets.all(8),
468 padding: const pw.EdgeInsets.all(8),
469 child: pw.Text(
'BILL/202411/27/0006'),
476 padding: const pw.EdgeInsets.all(8),
478 'Collection Order Ref',
482 padding: const pw.EdgeInsets.all(8),
483 child: pw.Text(
'${collection.name}/INV2024'),
486 padding: const pw.EdgeInsets.all(8),
492 padding: const pw.EdgeInsets.all(8),
493 child: pw.Text(
'CASH'),
500 padding: const pw.EdgeInsets.all(8),
502 'Collection Confirmation Ref',
506 padding: const pw.EdgeInsets.all(8),
507 child: pw.Text(
'WH/IN00061'),
510 padding: const pw.EdgeInsets.all(8),
516 padding: const pw.EdgeInsets.all(8),
517 child: pw.Text(
'POSTED'),
523 pw.SizedBox(height: 30),
526 pw.Table.fromTextArray(
534 data: List.generate(1, (index) {
536 '[UCO] Used cooking oil',
537 '${collection.orderLines?.first.productQty} L',
538 '${collection.orderLines?.first.productQty ?? 0 - 10} Kg',
542 cellAlignment: pw.Alignment.centerLeft,
546 padding: pw.EdgeInsets.all(5.sp),
547 decoration: pw.BoxDecoration(
549 left: pw.BorderSide(
color: PdfColor(0, 0, 0), width: 1),
550 right: pw.BorderSide(
color: PdfColor(0, 0, 0), width: 1),
551 bottom: pw.BorderSide(
color: PdfColor(0, 0, 0), width: 1),
552 top: pw.BorderSide.none,
556 mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
560 'Payment Amount: ${NumberFormat.compact().format((collection.orderLines?.first.productQty ?? 0 - 10) * 2.2)}',
566 pw.SizedBox(height: 30),
568 mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
569 children: [directorSignature, collectorSignature],
571 pw.SizedBox(height: 30),
573 mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
574 crossAxisAlignment: pw.CrossAxisAlignment.end,
577 'STRICTLY CONFIDENTIAL',
580 mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
583 pw.SizedBox(width: 10),
594 final output = await getTemporaryDirectory();
596 File(
'${output.path}/collection_voucher_with_table_and_payment.pdf');
597 await file.writeAsBytes(await pdf.save());
599 OpenFilex.open(file.path);