koi_printer_command 0.1.0
koi_printer_command: ^0.1.0 copied to clipboard
Print document model and command renderers for koi_printer. Supports ESC/POS, TSPL, and CPCL protocols.
// ignore_for_file: avoid_print // rationale: example app
import 'package:koi_printer_command/koi_printer_command.dart';
void main() async {
// 1. Create a print document with abstract elements
const document = KoiTicketDocument(
elements: [
KoiTextElement(
text: 'Koi Printer Studio',
bold: true,
size: KoiTextSize.size2,
align: KoiTextAlign.center,
),
KoiTextElement(text: '--------------------------------'),
KoiBarcodeElement(data: '20260507'),
KoiTextElement(text: '--------------------------------'),
KoiCutElement(),
],
);
// 2. Render to ESC/POS bytes
const escPosRenderer = KoiEscPosRenderer();
final escPosBytes = escPosRenderer.render(document);
print('Generated ${escPosBytes.length} chunks for ESC/POS.');
// 3. Render to TSPL bytes
const tsplRenderer = KoiTsplRenderer();
final tsplBytes = tsplRenderer.render(document);
print('Generated ${tsplBytes.length} chunks for TSPL.');
}