Advertisement
kendy2900

desain printer

Apr 26th, 2022
970
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 3.15 KB | None | 0 0
  1. void _tesPrint(
  2.       {Pam? pam,
  3.       TransactionAllModel? tm,
  4.       List<CostDetail>? result,
  5.       int? totalPrice,
  6.       int? fee}) async {
  7.     //SIZE
  8.     // 0- normal size text
  9.     // 1- only bold text
  10.     // 2- bold with medium text
  11.     // 3- bold with large texts
  12.     //ALIGN
  13.     // 0- ESC_ALIGN_LEFT
  14.     // 1- ESC_ALIGN_CENTER
  15.     // 2- ESC_ALIGN_RIGHT
  16.  
  17.     bluetooth.isConnected.then((isConnected) {
  18.       if (isConnected!) {
  19.         if (pam != null) {
  20.           if (pam.name != null && pam.name!.isNotEmpty) {
  21.             bluetooth.printCustom("${pam.name}", 0, 1);
  22.           }
  23.           if (pam.detailAddress != null && pam.detailAddress!.isNotEmpty) {
  24.             bluetooth.printCustom("${pam.detailAddress}", 0, 1);
  25.           }
  26.         }
  27.         bluetooth.printCustom("================================", 1, 1);
  28.         bluetooth.printCustom("Di tagihkan Kepada", 0, 1);
  29.         if (tm != null) {
  30.           if (tm.name != null && tm.name!.isNotEmpty) {
  31.             bluetooth.printNewLine();
  32.             bluetooth.printNewLine();
  33.             bluetooth.printCustom("${tm.name}", 0, 1);
  34.           }
  35.           if (tm.address != null && tm.address!.isNotEmpty) {
  36.             bluetooth.printCustom("${tm.address}", 0, 1);
  37.           }
  38.           if (tm.uniqueId != null && tm.uniqueId!.isNotEmpty) {
  39.             bluetooth.printCustom("${tm.uniqueId}", 0, 1);
  40.           }
  41.         }
  42.         bluetooth.printCustom("================================", 1, 1);
  43.  
  44.         bluetooth.printCustom("RINCIAN PEMAKAIAN", 0, 1);
  45.         if (tm != null) {
  46.           if (tm.starMeter != null && tm.starMeter!.isNotEmpty) {
  47.             bluetooth.printLeftRight("METER AWAL", "${tm.starMeter}", 0);
  48.           } else {
  49.             bluetooth.printLeftRight("METER AWAL", " ", 0);
  50.           }
  51.           if (tm.meterLast != null && tm.meterLast!.isNotEmpty) {
  52.             bluetooth.printLeftRight("METER AKHIR", "${tm.meterLast}", 0);
  53.           } else {
  54.             bluetooth.printLeftRight("METER AKHIR", " ", 0);
  55.           }
  56.           if (tm.meterNow != null && tm.meterNow!.isNotEmpty) {
  57.             bluetooth.printLeftRight("VOLUME", "${tm.meterNow}", 0);
  58.           } else {
  59.             bluetooth.printLeftRight("VOLUME", " ", 0);
  60.           }
  61.         }
  62.         bluetooth.printCustom("================================", 1, 1);
  63.         bluetooth.printCustom("RINCIAN BIAYA", 0, 1);
  64.         result!.map((product) {
  65.           String qtyBrg = product.meter.toString();
  66.           String hrgBrg = rupiah(product.cost?.toInt());
  67.           // double subtotal = product.transactionQuantity *
  68.           //     product.transactionSinglePrice.toDouble();
  69.           String subtotal = rupiah(int.parse(product.total!));
  70.           // String subtot = rupiah(subtotal.toInt());
  71.  
  72.           bluetooth.printLeftRight("$qtyBrg   x   $hrgBrg", subtotal, 1);
  73.         }).toList();
  74.         bluetooth.printCustom("--------------------------------", 1, 1);
  75.         bluetooth.printLeftRight("Subtotal        Rp", "$totalPrice", 1);
  76.         bluetooth.printLeftRight("Biaya Admi      Rp", "$fee", 1);
  77.  
  78.         bluetooth.printNewLine();
  79.         bluetooth.printNewLine();
  80.       }
  81.     });
  82.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement