update latest

This commit is contained in:
Tothemax Dev
2024-09-27 16:15:19 +07:00
parent 5419429426
commit 88c298cc79
9 changed files with 329 additions and 575 deletions

View File

@@ -1,6 +1,7 @@
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:max_print_plus/max_print_plus.dart';
import 'package:max_print_plus/print/max_print.dart';
void main() {
@@ -53,8 +54,7 @@ class _MyHomePageState extends State<MyHomePage> {
child: Text('Click me')),
ElevatedButton(
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => MaxPrint()));
_printReceiveTest(true);
},
child: Text('Print page mode')),
],
@@ -63,220 +63,210 @@ class _MyHomePageState extends State<MyHomePage> {
));
}
// Future _printReceiveTest(bool isPage) async {
// List<int> bytes = [];
Future _printReceiveTest(bool isPage) async {
List<int> bytes = [];
// // Xprinter XP-N160I
// final profile = await CapabilityProfile.load(name: 'XP-N160I');
// Xprinter XP-N160I
final profile = await CapabilityProfile.load(name: 'XP-N160I');
// // PaperSize.mm80 or PaperSize.mm58
// final generator = Generator(PaperSize.mm58, profile);
// bytes += generator.setGlobalCodeTable('CP1252');
// bytes += generator.text('MM TOYS',
// styles: const PosStyles(align: PosAlign.center, bold: true));
// PaperSize.mm80 or PaperSize.mm58
final generator =
EscGenerator(PaperSizeWidth.mm58, PaperSizeMaxPerLine.mm58, profile);
bytes += generator.setGlobalCodeTable('CP1252');
bytes += generator.text('MM TOYS',
styles: const PosStyles(align: PosAlign.center, bold: true));
// bytes += generator.text('Cikijing, Talaga, Bantarujeg, Rancah',
// styles: const PosStyles(align: PosAlign.center, bold: true));
bytes += generator.text('Cikijing, Talaga, Bantarujeg, Rancah',
styles: const PosStyles(align: PosAlign.center, bold: true));
// bytes += generator.row([
// PosColumn(
// width: 6,
// text: 'PENJUALAN :',
// styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
// PosColumn(
// width: 6,
// text: '2024-03-14',
// styles: const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
// ]);
bytes += generator.row([
PosColumn(
width: 6,
text: 'PENJUALAN :',
styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
PosColumn(
width: 6,
text: '2024-03-14',
styles: const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
]);
// bytes += generator.row([
// PosColumn(
// width: 8,
// text: 'PELANGGAN : UMUM-RCH',
// styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
// PosColumn(
// width: 4,
// text: '15:30',
// styles: const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
// ]);
bytes += generator.row([
PosColumn(
width: 8,
text: 'PELANGGAN : UMUM-RCH',
styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
PosColumn(
width: 4,
text: '15:30',
styles: const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
]);
// bytes += generator.text('--------------------------------',
// styles: const PosStyles(align: PosAlign.center));
// bytes += generator.row([
// PosColumn(
// width: 6,
// text: 'Qty',
// styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
// PosColumn(
// width: 6,
// text: 'Nama Produk',
// styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
// ]);
bytes += generator.text('--------------------------------',
styles: const PosStyles(align: PosAlign.center));
bytes += generator.row([
PosColumn(
width: 6,
text: 'Qty',
styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
PosColumn(
width: 6,
text: 'Nama Produk',
styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
]);
// bytes += generator.row([
// PosColumn(
// width: 3,
// text: 'Harga',
// styles: const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
// PosColumn(
// width: 3,
// text: 'Dis.',
// styles: const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
// PosColumn(
// width: 3,
// text: 'PPn',
// styles: const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
// PosColumn(
// width: 3,
// text: 'Netto',
// styles: const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
// ]);
bytes += generator.row([
PosColumn(
width: 3,
text: 'Harga',
styles: const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
PosColumn(
width: 3,
text: 'Dis.',
styles: const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
PosColumn(
width: 3,
text: 'PPn',
styles: const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
PosColumn(
width: 3,
text: 'Netto',
styles: const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
]);
// bytes += generator.text('--------------------------------',
// styles: const PosStyles(align: PosAlign.center));
bytes += generator.text('--------------------------------',
styles: const PosStyles(align: PosAlign.center));
// // Dummy transaction data
// List<String> dummyProducts = [
// 'Product 1',
// 'Product 2',
// 'Product 3',
// ];
// Dummy transaction data
List<String> dummyProducts = [
'Product 1',
'Product 2',
'Product 3',
];
// for (var productName in dummyProducts) {
// bytes += generator.row([
// PosColumn(
// width: 12,
// text: '2 ${productName.toUpperCase()}',
// styles: const PosStyles(
// align: PosAlign.left,
// codeTable: 'CP1252',
// )),
// ]);
for (var productName in dummyProducts) {
bytes += generator.row([
PosColumn(
width: 12,
text: '2 ${productName.toUpperCase()}',
styles: const PosStyles(
align: PosAlign.left,
codeTable: 'CP1252',
)),
]);
// bytes += generator.row([
// PosColumn(
// width: 3,
// text: '10.0',
// styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
// PosColumn(
// width: 3,
// text: '0.0',
// styles:
// const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
// PosColumn(
// width: 3,
// text: '',
// styles:
// const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
// PosColumn(
// width: 3,
// text: '20.0',
// styles:
// const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
// ]);
// }
bytes += generator.row([
PosColumn(
width: 3,
text: '10.0',
styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
PosColumn(
width: 3,
text: '0.0',
styles:
const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
PosColumn(
width: 3,
text: '',
styles:
const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
PosColumn(
width: 3,
text: '20.0',
styles:
const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
]);
}
// bytes += generator.text('--------------------------------',
// styles: const PosStyles(align: PosAlign.center));
bytes += generator.text('--------------------------------',
styles: const PosStyles(align: PosAlign.center));
// // Dummy total and payment data
// bytes += generator.row([
// PosColumn(
// width: 4,
// text: 'Jumlah : 3',
// styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
// PosColumn(
// width: 4,
// text: 'Item : 6',
// styles: const PosStyles(align: PosAlign.center, codeTable: 'CP1252')),
// PosColumn(
// width: 4,
// text: '33.0',
// styles: const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
// ]);
// Dummy total and payment data
bytes += generator.row([
PosColumn(
width: 4,
text: 'Jumlah : 3',
styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
PosColumn(
width: 4,
text: 'Item : 6',
styles: const PosStyles(align: PosAlign.center, codeTable: 'CP1252')),
PosColumn(
width: 4,
text: '33.0',
styles: const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
]);
// // Dummy grand total, payment, change, and cashier data
// bytes += generator.row([
// PosColumn(
// width: 6,
// text: 'Grand Total',
// styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
// PosColumn(
// width: 1,
// text: ':',
// styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
// PosColumn(
// width: 5,
// text: '33.0',
// styles: const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
// ]);
// bytes += generator.row([
// PosColumn(
// width: 6,
// text: 'Pembayaran',
// styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
// PosColumn(
// width: 1,
// text: ':',
// styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
// PosColumn(
// width: 5,
// text: '50.0',
// styles: const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
// ]);
// bytes += generator.row([
// PosColumn(
// width: 6,
// text: 'Kembalian',
// styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
// PosColumn(
// width: 1,
// text: ':',
// styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
// PosColumn(
// width: 5,
// text: '17.0',
// styles: const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
// ]);
// bytes += generator.row([
// PosColumn(
// width: 6,
// text: 'Kasir',
// styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
// PosColumn(
// width: 6,
// text: 'Anisa',
// styles: const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
// ]);
// Dummy grand total, payment, change, and cashier data
bytes += generator.row([
PosColumn(
width: 6,
text: 'Grand Total',
styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
PosColumn(
width: 1,
text: ':',
styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
PosColumn(
width: 5,
text: '33.0',
styles: const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
]);
bytes += generator.row([
PosColumn(
width: 6,
text: 'Pembayaran',
styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
PosColumn(
width: 1,
text: ':',
styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
PosColumn(
width: 5,
text: '50.0',
styles: const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
]);
bytes += generator.row([
PosColumn(
width: 6,
text: 'Kembalian',
styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
PosColumn(
width: 1,
text: ':',
styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
PosColumn(
width: 5,
text: '17.0',
styles: const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
]);
bytes += generator.row([
PosColumn(
width: 6,
text: 'Kasir',
styles: const PosStyles(align: PosAlign.left, codeTable: 'CP1252')),
PosColumn(
width: 6,
text: 'Anisa',
styles: const PosStyles(align: PosAlign.right, codeTable: 'CP1252')),
]);
// bytes += generator.text('--------------------------------',
// styles: const PosStyles(align: PosAlign.center));
bytes += generator.text('--------------------------------',
styles: const PosStyles(align: PosAlign.center));
// bytes += generator.text(
// 'BARANG YANG SUDAH DI BELI TIDAK DAPAT DITUKAR / DIKEMBALIKAN',
// styles: const PosStyles(align: PosAlign.center));
// bytes += generator.text('TERIMA KASIH',
// styles: const PosStyles(align: PosAlign.center));
bytes += generator.text(
'BARANG YANG SUDAH DI BELI TIDAK DAPAT DITUKAR / DIKEMBALIKAN',
styles: const PosStyles(align: PosAlign.center));
bytes += generator.text('TERIMA KASIH',
styles: const PosStyles(align: PosAlign.center));
// if (isPage == false) {
// _showPrintDialog(bytes, generator);
// } else {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => MaxPrintPage(
// bytes: bytes,
// generator: generator,
// title: 'Test',
// description: 'Test',
// onSuccess: () {
// Navigator.pop(context);
// log('Printed');
// },
// appBar: null,
// )));
// }
// }
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MaxPrint(
bytes: bytes,
generator: generator,
)));
}
// _showPrintDialog(List<int> bytes, Generator generator) {
// return showDialog(

View File

@@ -105,22 +105,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.7.10"
dio:
dependency: transitive
description:
name: dio
sha256: "5598aa796bbf4699afd5c67c0f5f6e2ed542afc956884b9cd58c306966efc260"
url: "https://pub.dev"
source: hosted
version: "5.7.0"
dio_web_adapter:
dependency: transitive
description:
name: dio_web_adapter
sha256: "33259a9276d6cea88774a0000cfae0d861003497755969c92faa223108620dc8"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
drago_blue_printer:
dependency: transitive
description:
@@ -145,14 +129,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.1.0"
easy_logger:
dependency: transitive
description:
name: easy_logger
sha256: c764a6e024846f33405a2342caf91c62e357c24b02c04dbc712ef232bf30ffb7
url: "https://pub.dev"
source: hosted
version: "0.0.2"
fake_async:
dependency: transitive
description:
@@ -279,14 +255,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
js:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.6.7"
leak_tracker:
dependency: transitive
description:
@@ -319,14 +287,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.0"
logging:
dependency: transitive
description:
name: logging
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
matcher:
dependency: transitive
description:
@@ -542,14 +502,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.8"
pool:
dependency: transitive
description:
name: pool
sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a"
url: "https://pub.dev"
source: hosted
version: "1.5.1"
printing:
dependency: transitive
description:
@@ -566,14 +518,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.0.2"
puppeteer:
dependency: transitive
description:
name: puppeteer
sha256: fc33b2a12731e0b9e16c40cd91ea2b6886bcc24037a435fceb59b786d4074f2b
url: "https://pub.dev"
source: hosted
version: "3.15.0"
qr:
dependency: transitive
description:
@@ -743,10 +687,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev"
source: hosted
version: "14.2.4"
version: "14.2.5"
web:
dependency: transitive
description:
@@ -755,14 +699,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.1.0"
webcontent_converter:
dependency: transitive
description:
name: webcontent_converter
sha256: dab8a6abda92eb83e168d92a66f1b174f7e8c317351e6cc868440a1c1343d5f5
url: "https://pub.dev"
source: hosted
version: "0.0.9+2"
webdriver:
dependency: transitive
description: