zcs_sdk_plugin 1.2.0
zcs_sdk_plugin: ^1.2.0 copied to clipboard
A Flutter plugin for ZCS SDK integration. Provides universal dynamic printing for receipts, invoices, and documents with QR codes, dual copies, and configurable layouts. Includes printRawText for simp [...]
1.2.0 Raw Text Printing #
✨ New Features #
- Raw Text Printing: Added
printRawText()method for simple text printing- Print plain text strings directly without formatting structure
- Supports newline characters (
\n) for multi-line printing - Uses default formatting (24pt font, left-aligned)
- Perfect for simple printing needs
- Automatic line splitting and error handling
🔧 Implementation Details #
- Added
printRawText(String text)to platform interface - Implemented in MethodChannel for Flutter-Android communication
- Native Android implementation using
mPrinter.setPrintAppendString() - Thread-safe execution on background executor
- Comprehensive error handling
📚 Documentation #
- Added usage examples in README.md
- Updated example app with "Print Raw Text" button
- Inline documentation with code examples
💡 Usage Example #
final plugin = ZcsSdkPlugin();
await plugin.initializeDevice();
await plugin.openDevice();
await plugin.printRawText('Hello, World!\nThis is a test print.\n');
1.1.0 Serial Number Support #
✨ New Features #
- Device Serial Number Retrieval: Added
getSerialNumber()method- Asynchronous implementation using background thread
- Retrieves unique device serial number from ZCS SDK
- Comprehensive error handling with detailed error messages
- Returns
String?with serial number ornullon error
- Updated example app with "Get Serial Number" button for testing
🔧 Implementation Details #
- Added
getSerialNumber()to platform interface - Implemented in MethodChannel for Flutter-Android communication
- Native Android implementation using
Sys.getSN()from ZCS SDK - Proper error code handling (SDK_OK, SDK_ERR, SDK_ERR_NOT_INIT, SDK_ERR_PARAM)
- Thread-safe execution on background executor
📚 Documentation #
- Added comprehensive usage examples in main plugin class
- Inline documentation for all new methods
1.0.0 Major Refactoring #
🎉 Universal Dynamic Printing Engine #
BREAKING CHANGES:
- Removed
printText(),printReceipt(),printQRCode(), andprintImage()methods - Replaced with single universal method:
printDynamic()
✨ New Features #
- Universal Dynamic Printing: Single
printDynamic()method handles all document types- Receipts, invoices, reports, warehouse dispatches, and any custom document
- Automatic field skipping for null/empty values
- Flexible layout styles:
simple,detailed,compact - Smart text handling with auto-wrapping and truncation
- Dynamic QR code generation from any field
- Dual copy printing (customer + merchant)
- Configurable pause between copies: Added
pauseBetweenCopiesparameter (default: 5 seconds) to allow users to cut the first copy before the second one prints - Nested map support for complex data structures
- UTF-8 support for special characters (KSh, etc.)
🔧 Architecture Improvements #
- Helper methods for clean code organization:
printDocumentCopy()- Renders one copyprintFields()- Prints key-value pairs with recursive nesting supportprintKeyValue()- Formats single KV linesprintItemsTable()- Renders items as formatted tableprintTotals()- Prints financial totals sectionprintQRCodeHelper()- QR code generationcreateFormat()- Text format helpergetStringValue()- Safe value extraction
📚 Documentation #
- Added comprehensive
DYNAMIC_PRINTING_GUIDE.mdwith examples - Added
REFACTORING_SUMMARY.mddocumenting all changes - Updated
README.mdwith new API and examples - Added inline code documentation
🎯 Benefits #
- ✅ Reduced code complexity (~300 lines of duplicate code removed)
- ✅ Maximum flexibility for any document type
- ✅ Single API method to learn and maintain
- ✅ Professional output with consistent formatting
- ✅ Easy to extend for new document types
Migration Guide #
Before (v0.x):
await plugin.printText('Hello');
await plugin.printReceipt(receiptData);
await plugin.printQRCode('DATA');
After (v1.0):
await plugin.printDynamic({
'header': 'Hello',
'fields': {...},
'items': [...],
'qrCodeField': 'id',
'id': 'DATA',
}, bothCopies: false);
0.0.1 #
- Initial release with basic printing functionality