flutter_zpl_generator 2.0.0
flutter_zpl_generator: ^2.0.0 copied to clipboard
A comprehensive Flutter package for generating ZPL (Zebra Programming Language) labels with Labelary API integration and live preview capabilities.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
2.0.0 - 2026-04-20 #
BREAKING CHANGES #
- Deleted
ZplImage— replaced by three explicit commands:ZplImageDownload(emits~DG; newZplControlCommandbase).ZplImageRecall(emits^FO+^XG).ZplImageInline(emits^FO+^GFA, one-shot ACS).
- Deleted
ZplFontAsset— replaced byZplFontUpload(also aZplControlCommand). Load viaawait ZplFontUpload.fromAsset(...). - Removed
ZplGenerator.fontsandZplGenerator.assetServiceparameters. PassZplFontUploadinstances inline incommands:. - Removed
ZplAssetService.getFontUploadCommand().loadFontBytes()replaces its role as the low-level asset read. ZplText.customFonttype changed fromZplFontAsset?toZplFontUpload?.
See doc/migration-v1-to-v2.md for per-pattern migration recipes.
Fixed #
- Bug 1 (critical):
~DGand~DYnow emit before^XAas Zebra's ZPL II Programming Guide recommends. Link-OS mobile printers (ZQ620 V85.20 etc.) print reliably; previously the tilde-inside- format layout caused blank labels or silently discarded jobs. - Bug 2:
ZplImageDownload.width/.height(and matching getters onZplImageInline) now return POST-resize dimensions, including aspect-preserving scale when only one axis is specified. Unblocks^LL = image.heightfor every caller. - Bug 4: ACS run-length encoder dropped the trailing
1count after a multi-of-20 chunk (runs of 21, 41, …, 401). Fix localised inimage_payload_builder.dart::compressRow.
Added #
ZplControlCommandabstract subclass ofZplCommand; subclass it to author any tilde-prefixed command.ZplGenerator.autoLabelLengthFromFirstImage: bool— when enabled and no explicitZplConfiguration.labelLengthis set, emits^LL<firstDownload.height>inside the format. (Bug 3)- ACS encoder round-trip test suite with boundary and fuzz coverage.
doc/migration-v1-to-v2.md.doc/mobile-printer-guide.md— Link-OS firmware caveats, thermal protection advisory, observed-working ZPL reference.
1.5.1 - 2026-03-28 #
Fixed #
- Native Preview Fixes: Stabilized anti-aliasing artifacts on
ZplCanvasPainterthat resulted in edge-bleeding in scannable offline barcode widgets. Corrected module-width distortion calculation for 1D and 2D barcodes ensuring perfect native preview parity to printer firmware output. - Native Preview Images: Upgraded offline native preview to now physically dither and render image payloads directly within the Flutter canvas securely, rather than just displaying a blue placeholder bounds.
1.5.0 - 2026-03-28 #
The "Native Preview & Advanced Typography" Release.
Added #
- Native Offline Canvas Preview: Added
ZplNativePreviewandZplCanvasPainterfor high-performance offline rendering of ZPL layouts in Flutter without relying on external network calls. - Advanced Typography (
^PA): AddedZplAdvancedTextPropertiesfor fine-grained control over text alignment and styling. - Text Blocks (
^TB): AddedZplTextBlocksupport, natively integrated intoZplGridRowandZplColumnfor complex rich-text layouts. - Zebra BASIC Interpreter (ZBI) Commands: Implemented
ZplZbiStart(~JI),ZplZbiStop(~JQ),ZplHostQuery(~HQ), andZplEarlyWarning(^JH) for programmatic printer control and bidirectional host querying.
Dependencies #
- Added
barcode: ^2.2.9to support native offline barcode generation.
1.4.0 - 2026-03-28 #
The "Enterprise Networking & Hardware Integrations" Release.
Added #
- Hardware Network Configuration: Comprehensive suite of commands for configuring ZPL printer networks natively.
ZplNetworkSettings(^ND): Interface for changing primary IP, subnet, gateway, resolving timeouts for a device.ZplNetworkWiredSettings(^NS): Wired-specific network configurations matching dynamic addressing.ZplNetworkSnmp(^NN): Full configuration of Simple Network Management Protocol parameters (community strings, location, contact, traps).ZplNetworkSmtp(^NT): Define printer SMTP email routing server details.- Operations for device connection limits (
^NC,~NC,^NP), ID assignment (^NI), firmware boot server routines (^NB), and password timeouts (^NW).
- Printer Transparency Management: Address downstream printers linked off a primary printer port using
ZplNetworkPrintersTransparentAll(~NR) andZplNetworkPrinterTransparentCurrent(~NT). - Graphic Symbols (
^GS): AddedZplGraphicSymbolutility allowing for hardware-native validation and rendering of standard registered trademark (®), copyright (©), UL, CSA, and VDE symbols.
1.3.0 - 2026-03-26 #
The "Enterprise Print Batching & Compression" Release.
Added #
- Native Print Quantity (
^PQ): Control batches dynamically withZplPrintQuantity. Set quantity counts, overrides, pausing, and cut intervals mathematically outside of strings. - Auto-Increment Serialization (
^SN): Embed native hardware serialization withZplSerializationmappingstart,increment, andpadcontrols natively into ZPL blocks. - ACS Image Compression (
^GFA): Greatly optimized print times by compressing binary string images natively intoacsrun-length encodedZplImageCompressionoutputs. Drops image payload payload size by 60-90%. - Conditional Layout Support (
ZplConditional): Drop-in wrapper that renders layout elements recursively conditionally based on abool. Works natively insideZplGridRowandZplColumngracefully mapping mathematical zeroes preventing spacing gaps!
1.2.0 - 2026-03-26 #
The "Enterprise RFID & Smart Imaging" Release.
Added #
- Enterprise RFID Tag Encoding: New
ZplRfidSetup(^RS) andZplRfidWrite(^RF) commands for simultaneous print-and-encode workflows on Zebra RFID printers (e.g., ZT411 RFID).- Supports all Gen 2 memory banks: Reserved, EPC, TID, User.
- Full operation set: Write, Write with Lock, Read, Read Password, Specify Password, Encode.
- Data formats: ASCII, Hexadecimal, EPC.
- Runtime
ArgumentErrorvalidation for hex payloads to prevent silent printer failures.
- Advanced Image Dithering:
ZplImagenow supportsZplDitheringAlgorithmwith three modes:floydSteinberg(new default) — smooth error diffusion for natural-looking gradients.atkinson— high contrast dot patterns with a vintage newspaper print aesthetic.threshold— legacy hard black/white clipping behavior.
- Templating & Data Binding Engine: New
ZplTemplateclass for high-performance mass-label generation.- Define layouts with
{{variable}}placeholders in anyZplText,ZplBarcode, etc. init()pre-compiles the layout once (fonts, images, grid math).bindSync()enables zero-overhead synchronous label stamping in tight loops.
- Define layouts with
Changed #
- Default image dithering algorithm changed from
thresholdtofloydSteinbergfor significantly better print quality out of the box.
1.1.1 - 2026-03-22 #
Fixed #
- Fixed placeholder yourusername GitHub URLs in
pubspec.yamland pointed them correctly to minhtri1401.
1.1.0 - 2026-03-22 #
The "Library Finalization & Layout Redux" Release.
Added #
- 12-Unit Grid Layout Engine: Overhauled horizontal layouts by introducing
ZplGridRowandZplGridColfor robust proportional layouts and offsets without requiring string hacks. - Graphic Shapes: Added
ZplGraphicCircle(^GC),ZplGraphicEllipse(^GE), andZplGraphicDiagonalLine(^GD). - Raw Escape Hatch: Added
ZplRawcommand allowing developers to inject arbitrary raw ZPL string segments cleanly into the hierarchy. - Advanced Barcode Formats: Upgraded
ZplBarcodeTypewith native support forDataMatrix(^BX), European Article Numberean13(^BE), and Universal Product CodeupcA(^BU). - Reverse Colors: Added
reversePrintparameter to display standard white-on-black inverse patterns (^FR) inZplTextandZplBox.
Changed #
- BREAKING:
ZplConfigurationis no longer passed as a fake object inside thecommandsarray. It is now passed directly as a root parameter to the generator:ZplGenerator(config: ..., commands: [...]). - ZplPreview Reactivity:
ZplPreviewwidget is now fully reactive and correctly implements Flutter'sdidUpdateWidget(), automatically rerendering images optimally when configurations or properties change. - Networking Compliance:
LabelaryServiceREST network calls were updated to enforce properContent-Typeheaders ensuring better proxy network pass-throughs. - Internal layout rendering logic entirely rewritten.
toZpl()now takes aZplConfiguration context, enforcing parent bound limits likemaxWidthimplicitly down through children layers.
Removed #
- BREAKING: Completely deleted the outdated and brittle
ZplRowcomponent. Use the superior mathematically drivenZplGridRowinstead.
1.0.0 - 2024-03-15 #
Added #
Core Features
- ZPL Command Support: Complete implementation of essential ZPL commands
ZplConfiguration: Label setup with print width, length, density, and orientationZplText: Text rendering with font selection, sizing, and positioningZplBarcode: Comprehensive barcode support (Code128, QR Code, UPC, EAN, etc.)ZplImage: Image embedding with PNG and other format supportZplBox: Rectangle and border drawing with customizable thicknessZplRowandZplColumn: Layout helpers for organized label design
Labelary API Integration
- Complete API Support: Full integration with Labelary rendering service
- Basic ZPL rendering to PNG, PDF, and other formats
- Advanced features: label rotation, PDF customization, print quality control
- ZPL linting with detailed error reporting
- Response metadata including label count and warnings
- Image Conversion: Convert images to ZPL graphics commands
- Font Conversion: Convert TrueType fonts to ZPL font commands
- Multiple Content Types: Support for both raw ZPL strings and file uploads
Flutter Integration
- ZplPreview Widget: Live preview widget for Flutter applications
- Automatic rendering using Labelary API
- Loading, success, and error state handling
- Easy integration with any Flutter app
- Type Safety: Strongly typed enums and classes for all ZPL parameters
- Cross-Platform: Support for iOS, Android, Web, macOS, Windows, and Linux
Developer Experience
- Comprehensive Examples: Multiple example files demonstrating usage patterns
- Extensive Testing: Unit tests and integration tests with Labelary API
- Documentation: Detailed API documentation and usage examples
- Error Handling: Descriptive error messages and graceful failure handling
Technical Details #
Supported ZPL Commands
^XA/^XZ: Label start and end^LL: Label length configuration^PR: Print rate/density settings^JM: Memory allocation mode^FO: Field origin positioning^A0N,^AAN,^ABN: Font selection and sizing^FD/^FS: Field data definition^GB: Graphic box drawing^BY: Barcode element width^BCN,^B3N,^BQN: Various barcode types- Custom font loading and usage
Supported Barcode Types
- Code 128 (most common)
- QR Code with error correction
- UPC-A and UPC-E
- EAN-8 and EAN-13
- Code 39
- Interleaved 2 of 5
- And many more standard formats
Labelary API Features
- Label rendering in multiple formats (PNG, PDF, EPL, IPL, DPL, SBPL, PCL)
- Label rotation (0°, 90°, 180°, 270°)
- PDF page customization (size, orientation, layout, borders)
- Print quality control (grayscale vs bitonal)
- ZPL linting and validation
- Multiple labels per request support
- Image and font conversion services
Package Architecture
- Clean separation between ZPL generation and rendering
- Modular command-based design for easy extension
- Backward compatibility with simple method variants
- Efficient memory usage and network handling
- Comprehensive error handling and validation
Dependencies #
flutter: Flutter SDKimage: ^4.2.0 for image processinghttp: ^1.1.0 for API communication
Development Dependencies #
flutter_test: Testing frameworkflutter_lints: Code quality and style enforcementmockito: Mock testing for API callsbuild_runner: Code generation support
Platform Support #
- ✅ Android
- ✅ iOS
- ✅ Web
- ✅ macOS
- ✅ Windows
- ✅ Linux
Breaking Changes #
None - this is the initial release.
Migration Guide #
This is the first stable release. No migration needed.
Known Issues #
None at release time.
Contributors #
- Initial development and design
- Comprehensive testing and documentation
- Community feedback and suggestions welcomed
Note: This package provides ZPL generation and rendering capabilities for Flutter applications. It integrates with the Labelary.com service for label preview and rendering, but does not require it for basic ZPL string generation.