zebra_printer 0.2.0
zebra_printer: ^0.2.0 copied to clipboard
Flutter management package for Zebra printers. Uses Zebra Link-OS SDK for Bluetooth & Network discovery, ZPL printing, and printer management.
Changelog #
0.2.0 Production Ready Release 🚀 #
Major Features & Improvements #
🎯 PrinterManager - Full Zebra SDK Integration
-
Discovery System
- Renamed
discoverPrinters()→startDiscovery()for clarity - Added Zebra SDK-powered discovery (
BluetoothDiscoverer,NetworkDiscoverer) - Supports 'bluetooth', 'network', and 'both' discovery modes
- Real-time callbacks:
onPrinterFound,onDiscoveryFinished - Discovery optimization to prevent premature finish callbacks
- Renamed
-
Connection Management
connect()now returnsFuture<bool>(previouslyFuture<Map<String, dynamic>>)disconnect()now returnsFuture<bool>(previouslyFuture<String>)- Added persistent connection support with
activeConnectiontracking - Enhanced
isConnected()to check specific address or general status - Connection state monitoring via
onConnectionStateChangedcallback
-
New Methods
getPairedPrinters()- ReturnsFuture<List<BluetoothDevice>>(all paired devices)unpairPrinter(address)- Removes device pairing via Android Bluetooth API- Uses Android API for pairing operations (Zebra SDK limitation)
-
Print Optimization ⚡
- Smart Connection Handling: Uses active connection when available, creates temporary otherwise
- Connection Caching: 10-second cache for repeated prints to same printer
- First-Print Fix: Robust readiness check with retry mechanism (3 attempts: 2s, 1s, 800ms)
- Fast Path: 300ms delay for active connections, 500ms for cached connections
- Lightweight Verification: Uses
SGD.GET("device.friendly_name")instead of heavygetCurrentStatus() - Eliminated "socket closed or timeout" errors on first print
- Optimized for rapid successive printing (warehouse/retail scenarios)
🔧 BluetoothManager - Generic Bluetooth
- Added
unpairDevice(address)method for consistency - Automatic disconnection before unpairing
- Maintains 100% Android Bluetooth API implementation
📱 Example App - Professional UI
- Dual-tab interface: "Zebra SDK" and "Bluetooth" tabs
- Shows discovered printers with type indicators (Bluetooth/Network)
- Paired device management with "Paired" button
- Unpair functionality with delete icon on each device
- Connection status indicators (green checkmark)
- Modern Material Design 3 with color-coded sections
- Comprehensive button set: Discover, Paired, Print, Status, Info, Disconnect
Android Native Improvements #
PrinterManager.java
- Architecture: 99% Zebra Link-OS SDK, 1% Android API (for pairing only)
- Added
Context,Handler,MethodChannelfor better lifecycle management - Implemented
ExecutorServicefor background operations - Connection caching with
lastConnectionTimemap (10s duration) - Multi-retry connection readiness check in
sendZplToPrinter() - All methods use Zebra SDK except
getPairedPrinters()andunpairPrinter()
BluetoothManager.java
- Architecture: 100% Android Bluetooth API
- Added
unpairDevice()method using reflection - Automatic disconnection before unpair operation
Dependencies & Permissions
- Added Jackson dependencies:
jackson-core,jackson-databind,jackson-annotations - Added Apache Commons:
commons-lang3 - Network permissions:
INTERNET,ACCESS_NETWORK_STATE,ACCESS_WIFI_STATE,CHANGE_WIFI_STATE,CHANGE_WIFI_MULTICAST_STATE - Updated Bluetooth permissions for Android 12+ compatibility
- NDK version set to
27.0.12077973
Documentation 📚 #
README.md
- New Section: "🏗️ Architecture & SDK Usage" with detailed comparison tables
- Android Native Implementation Comparison table
- Detailed Method Comparison for both managers
- Shows which methods use Zebra SDK vs Android Bluetooth API
- Explains why certain methods must use Android API
- Updated all API method signatures
- Added comprehensive code examples
- ZPL examples for barcodes, QR codes, receipts
New Files
- API comparison tables integrated into README
- All method signatures updated to reflect v0.2.0 changes
Breaking Changes ⚠️ #
-
Method Renames
discoverPrinters()→startDiscovery()
-
Return Type Changes
connect():Future<Map<String, dynamic>>→Future<bool>disconnect():Future<String>→Future<bool>getPairedPrinters():Future<List<Map<String, dynamic>>>→Future<List<BluetoothDevice>>
-
Method Behavior Changes
sendZplToPrinter(): Now uses active connection when available, creates temporary otherwisedisconnect(): Now accepts optional address parameter
Bug Fixes 🐛 #
- Fixed: "socket closed or timeout" error on first print after connect
- Fixed: Connection readiness timing issues
- Fixed: Discovery callbacks firing prematurely with "both" mode
- Fixed: Missing imports (
PrinterStatus, Jackson classes) - Fixed: Thread.sleep() unreported exceptions
- Fixed: NDK version mismatch warnings
Performance Enhancements 🚀 #
- 10x faster successive prints with connection caching (10s window)
- Active connection reuse reduces latency from ~2s to ~300ms
- Smart retry logic ensures first print reliability
- Lightweight status checks using SGD instead of full printer status
Testing & Quality #
- Comprehensive debug logging added throughout
- Example app demonstrates all features
- Tested with rapid successive printing scenarios
- Connection pooling verified for warehouse environments
0.1.9 #
- Removed iOS platform support
- Package now supports Android platform only
- Cleaned up iOS-related code and dependencies
- Translated example app to English
- Updated documentation to reflect Android-only support
0.1.8 #
- Previous iOS-related changes (now removed)
0.1.7 #
- Translated documentation to English
- Updated package documentation
0.1.6 #
- Package update
- Performance improvements
0.1.5 #
- Added missing files
- Updated configuration files
0.1.4 #
- Improved code format in example app
0.1.3 #
- Added example app
- Improved package structure
0.1.2 #
- Updated README file
- Added pub.dev badges
- Updated version information
0.1.1 #
- Updated GitHub repository information
- Fixed package name (com.example -> com.sameetdmr)
0.1.0 #
- Initial release
- Core features:
- Scan and discover Bluetooth devices
- Pair and unpair with Bluetooth devices
- Connect and disconnect from Zebra printers
- Send ZPL code to printers
- Check printer status
- Get printer information
- Enum usage:
- BluetoothDeviceType
- BluetoothBondState
- BluetoothConnectionState
- BluetoothScanState
- PrinterConnectionState
- PaperState
- HeadState
- PauseState
- Advanced Bluetooth connection management
- Zebra Link-OS SDK integration for Android