flutter_esc_pos_network_universal 1.0.0
flutter_esc_pos_network_universal: ^1.0.0 copied to clipboard
The library allows printing receipts using ESC/POS commands using thermal Wi-Fi/Ethernet printer.
Flutter ESC/POS Network Universal #
A high-performance, cross-platform (IO & Web) Flutter library for printing to ESC/POS thermal network printers (WiFi/Ethernet).
This package is a forked and extended version of flutter_esc_pos_network, rewritten for "universal" cross-platform support (IO & Web).
β¨ Key Features #
- π± Cross-Platform: Unified API for Android, iOS, Windows, macOS, Linux, and Web.
- πΌοΈ Widget Printing: Render any Flutter Widget directly to your thermal printer with
printWidget. - π Asynchronous Performance: Uses
compute(Isolates) for image processing to keep the UI thread smooth. - π Chunked Printing: Automatically splits long receipts into chunks to prevent buffer overflow and ensure smooth web printing.
- π Web Bridge: Native TCP support on Web via the Local TCP Extension.
- π Real-time Status: Broadcast stream for monitoring the availability of the web printing bridge.
- π Custom Paper Sizes: Robust support for 58mm, 72mm, and 80mm paper widths.
π Official Resources #
- GitHub Repository: Source Code
- GitHub Download Link: Download Source & Scripts
- Chrome Web Store: Local TCP Extension
- Video Tutorial: Setup Guide & Demo
π Getting Started #
Tip
For proper installation and implementation details, please check the example folder very well.
1. Unified Interface Usage #
import 'package:flutter_esc_pos_network_universal/flutter_esc_pos_network_universal.dart';
final printer = PrinterNetworkManager(
'192.168.1.100',
paperSize: ThermalPosPrinterPageSize.size80mm,
);
PosPrintResult connect = await printer.connect();
if (connect == PosPrintResult.success) {
// Print standard ESC/POS bytes
await printer.printTicket(ticketBytes);
printer.disconnect();
}
2. Printing a Flutter Widget #
await printer.printWidget(
context,
child: MyReceiptWidget(), // Any standard Flutter widget
);
π Web Architecture (The Bridge) #
Since standard web browsers cannot directly open TCP sockets, this package uses a Native Messaging Bridge:
- Extension: The Local TCP Chrome Extension acts as the bridge.
- Native Host: A small setup script (available on GitHub) runs on the user's computer to handle the actual TCP sockets.
- Seamless API: The package automatically detects the platform and routes commands through the extension if running on Web, providing a single, unified development experience.
π οΈ Performance Configuration #
You can tune the chunkHeight to balance printing speed vs. memory usage. The default is 100 pixels, which is optimized for smooth web printing.
final printer = PrinterNetworkManager(
host,
chunkHeight: 100, // Balanced for Web stability
);
π€ Support & PRs #
We welcome community contributions! Please report bugs, suggest features, or submit PRs to help improve the universal printing experience.
Built with β€οΈ by Algoramming Systems Ltd.