zpl_plugin_package 0.0.8
zpl_plugin_package: ^0.0.8 copied to clipboard
A Flutter plugin for Zebra ZPL printers. Supports WiFi connection, text, barcode, image and PDF printing, raw ZPL commands, and real-time connection monitoring. Android only.
zpl_plugin_package #
A Flutter plugin for Zebra ZPL label printers that enables WiFi-based connection, printing text, barcodes, images, and PDFs, sending raw ZPL commands, and real-time connection status monitoring.
Platform support: Android only.
Features #
- Connect to / disconnect from Zebra printers over WiFi (IP + port)
- Print text with font type, size, and orientation control
- Print barcodes (Code 39, EAN-8, UPC-E, Code 93, Code 128, EAN-13)
- Print images from Flutter assets
- Print PDF files from Flutter assets (first page rendered as bitmap)
- Send raw ZPL commands (string)
- Real-time connection monitoring via
isPrinterConnectedgetter - Clean lifecycle management with
dispose()
Installation #
Add the package to your pubspec.yaml:
dependencies:
zpl_plugin_package: ^0.0.8
Run:
flutter pub get
Usage #
Import and create an instance #
import 'package:zpl_plugin_package/flutter_zebra_plugin.dart';
class _MyState extends State<MyWidget> {
final _zebra = FlutterZebraIntegration();
@override
void dispose() {
_zebra.dispose(); // Always dispose to release the stream subscription
super.dispose();
}
}
Connect to printer #
final bool? success = await _zebra.connectToPrinter('192.168.1.100', '9100');
Disconnect #
await _zebra.disconnectPrinter();
Check connection status #
if (_zebra.isPrinterConnected) {
print('Printer is online');
}
Print text #
await _zebra.printText(
'Hello World',
x: '10',
y: '20',
type: 0, // font type: 0–6 = standard, 7 = Chinese
orientation: 'N', // N=0°, R=90°, I=180°, B=270°
size: 3, // 1=10px … 6=60px
);
Print barcode #
await _zebra.printBarcode(
'123456789012',
x: '10',
y: '20',
type: 4, // 0=Code39, 1=EAN-8, 2=UPC-E, 3=Code93, 4=Code128, 5=EAN-13
orientation: 'N',
height: '100',
f: 'Y', // 'Y' = show human-readable text, 'N' = hide
);
Print image (from Flutter assets) #
// Register the asset in pubspec.yaml first:
// flutter:
// assets:
// - assets/logo.png
await _zebra.printImage('assets/logo.png', x: '10', y: '10');
Print PDF (first page, from Flutter assets) #
await _zebra.printPDF('assets/document.pdf', x: '10', y: '10');
Send raw ZPL command #
await _zebra.sendZPLCommand('^XA^FO50,50^A0N,50,50^FDHello^FS^XZ');
API Reference #
| Method | Parameters | Returns | Description |
|---|---|---|---|
connectToPrinter |
ipAddress, port |
Future<bool?> |
Opens WiFi socket |
disconnectPrinter |
— | Future<bool?> |
Closes connection |
isPrinterConnected |
— | bool |
Current connection state |
printText |
textData, {x, y, type, orientation, size} |
Future<String?> |
Prints text |
printBarcode |
barcodeData, {x, y, type, orientation, height, f} |
Future<String?> |
Prints barcode |
printImage |
assetPath, {x, y} |
Future<String?> |
Prints image from assets |
printPDF |
assetPath, {x, y} |
Future<String?> |
Prints first PDF page from assets |
sendZPLCommand |
zplCommand |
Future<String?> |
Sends raw ZPL string |
getPlatformVersion |
— | Future<String?> |
Returns Android SDK version |
dispose |
— | void |
Cancels connection stream |
type values for printText #
| Value | Font |
|---|---|
| 0–6 | Standard fonts |
| 7 | Chinese font |
type values for printBarcode #
| Value | Symbology |
|---|---|
| 0 | Code 39 |
| 1 | EAN-8 |
| 2 | UPC-E |
| 3 | Code 93 |
| 4 | Code 128 (default) |
| 5 | EAN-13 |
orientation values #
| Value | Rotation |
|---|---|
N |
Normal (0°) |
R |
Clockwise 90° |
I |
Inverted 180° |
B |
Counter-clockwise 270° |
size values for printText #
| Value | Approximate size |
|---|---|
| 1 | 10 px |
| 2 | 20 px |
| 3 | 30 px (default) |
| 4 | 40 px |
| 5 | 50 px |
| 6 | 60 px |
Requirements #
| Requirement | Version |
|---|---|
| Flutter | ≥ 3.10.0 |
| Dart | ≥ 3.3.0 |
| Android minSdk | 21 (Android 5.0) |
| Android compileSdk | 34 |
iOS is not supported. The plugin uses Android's
PdfRendererand the proprietary ZebraZPLPrinterHelperJAR which are Android-only.
Architecture #
FlutterZebraIntegration ← public API (flutter_zebra_plugin.dart)
├── ZebraPrinterRepository ← MethodChannel / EventChannel bridge
├── PrinterConnectionManager ← listens to connection status stream
├── ImageService ← copies asset images to temp files
└── PDFService ← copies asset PDFs to temp files
The native Android side (ZplZebraPlugin.kt) handles all printer
communication through the bundled ZPL_V1.11.jar library, running
blocking I/O on background threads and posting results back to the main
thread via Handler.
License #
MIT License. See LICENSE for details.