flutter_esc_pos_network
이 라이브러리는 열식 Wi-Fi/이더넷 프린터를 사용하여 ESC/POS 명령을 통해 영수증을 인쇄할 수 있습니다.
mjafartp/flutter_esc_pos_network open-source repository details.
{"sdk":"flutter"}^1.0.1{"sdk":"flutter"}^1.0.0아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
The library allows to print receipts using an ESC/POS thermal WiFi/Ethernet printer. For Bluetooth printers, use esc_pos_bluetooth library.
It can be used in Flutter or pure Dart projects. For Flutter projects, both Android, iOS, windows, Linux and MacOS are supported.
To scan for printers in your network, consider using ping_discover_network package. Note that most of the ESC/POS printers by default listen on port 9100.
GS ( k command (printing QR code from an image already supported)GS ( k commandESC 3 <n> commandHere are some printers tested with this library. Please add the models you have tested to maintain and improve this library and help others to choose the right printer.
void testReceipt(NetworkPrinter printer) {
printer.text(
'Regular: aA bB cC dD eE fF gG hH iI jJ kK lL mM nN oO pP qQ rR sS tT uU vV wW xX yY zZ');
printer.text('Special 1: àÀ èÈ éÉ ûÛ üÜ çÇ ôÔ',
styles: PosStyles(codeTable: 'CP1252'));
printer.text('Special 2: blåbærgrød',
styles: PosStyles(codeTable: 'CP1252'));
printer.text('Bold text', styles: PosStyles(bold: true));
printer.text('Reverse text', styles: PosStyles(reverse: true));
printer.text('Underlined text',
styles: PosStyles(underline: true), linesAfter: 1);
printer.text('Align left', styles: PosStyles(align: PosAlign.left));
printer.text('Align center', styles: PosStyles(align: PosAlign.center));
printer.text('Align right',
styles: PosStyles(align: PosAlign.right), linesAfter: 1);
printer.text('Text size 200%',
styles: PosStyles(
height: PosTextSize.size2,
width: PosTextSize.size2,
));
printer.feed(2);
printer.cut();
}
You can find more examples here: flutter_esc_pos_utils.
import 'package:flutter_esc_pos_network/flutter_esc_pos_network.dart';
final printer = PrinterNetworkManager('192.168.1.100');
PosPrintResult connect = await printer.connect();
if (connect == PosPrintResult.success) {
PosPrintResult printing = await printer.printTicket(ticket);
print(printing.msg);
printer.disconnect();
}
}
For a complete example, check example/example.dart