Zebra Printer 🦓
A robust Flutter package for Zebra Link-OS™ Printers. Unlike generic Bluetooth plugins, this package leverages the official Zebra SDK to provide professional-grade discovery, status monitoring, and high-performance printing.
🚀 Key Features
- 🔍 Professional Discovery: Find Zebra printers via Bluetooth and Network using official Zebra SDK discovery algorithms.
- ⚡ Batch Printing: Print multiple labels in a single connection session—optimized for high-volume tasks.
- 📊 Real-time Status: Monitor paper out, head open, and pause states before you print.
- ℹ️ Device Intelligence: Fetch model names, serial numbers, and firmware versions automatically.
- 🛡️ SDK-Powered Stability: Built on Zebra Link-OS™ SDK for maximum compatibility and reliability.
- 🎯 Type-Safe Models: Modern Dart API with structured models for all printer data.
🏗️ Architecture
This package offers two managers to suit your needs:
- PrinterManager (Recommended): The core of the package. Uses the Zebra Link-OS™ SDK. Perfect for high-reliability production environments and detailed printer management.
- BluetoothManager: A lightweight utility for generic Bluetooth operations (scanning, pairing) using the standard Android API.
📦 Installation
Add the package to your pubspec.yaml:
dependencies:
zebra_printer: ^0.2.8
Android Configuration
Requires Android 5.0 (API 21) or higher. Add permissions to AndroidManifest.xml:
<!-- Bluetooth & Network Permissions -->
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
🛠️ Usage
Quick Start
import 'package:zebra_printer/zebra_printer.dart';
final printerManager = PrinterManager();
// 1. Discover
await printerManager.startDiscovery(type: DiscoveryType.bluetooth);
printerManager.onPrinterFound = (printer) => print('Found: ${printer.friendlyName}');
// 2. Print a single label
await printerManager.sendZplToPrinter('AC:3F:A4:XX:XX:XX', '^XA^FO50,50^A0N,50,50^FDZebra Flutter^FS^XZ');
// 3. ⚡ BATCH PRINT (Optimized)
List<String> labels = [
'^XA^FDLabel 1^XZ',
'^XA^FDLabel 2^XZ',
'^XA^FDLabel 3^XZ',
];
await printerManager.sendMultipleZplToPrinter('AC:3F:A4:XX:XX:XX', labels);
Detailed Status & Info
// Check if printer is ready
PrinterStatus status = await printerManager.checkPrinterStatus('AC:3F:A4:XX:XX:XX');
if (status.isPaperOut) print('Please load paper!');
// Get device details
PrinterInfo info = await printerManager.getPrinterInfo('AC:3F:A4:XX:XX:XX');
print('Printing to ${info.model} (S/N: ${info.serialNumber})');
🔧 Troubleshooting
- Printer Not Found: Ensure Bluetooth and Location services are ON. Grant permissions in system settings.
- Connection Failed: Ensure the printer isn't connected to another device. Zebra Bluetooth printers usually support only one active connection.
- Print Quality: Use
calibratePrinter(address, CalibrationType.gap)if your labels aren't aligned.
📑 ZPL Resource Tips
- Use the Zebra Labelary Viewer to test your ZPL code.
- Always wrap your code with
^XAand^XZ.
📜 Credits
- Powered by Zebra Link-OS™ SDK
- Developed and maintained by Samed Demir
⚖️ License
MIT License - Copyright (c) 2024 Samed Demir