totem_alecto 0.0.3
totem_alecto: ^0.0.3 copied to clipboard
Flutter plugin package for interfacing with Totem Alecto thermal printers, providing native Android support for printing operations
0.0.3 #
Fix the method to print image to be specific to print text images to avoid gray scale in background
0.0.2 #
Downgrade SDK version to work in older apps too
0.0.1 #
Added - Initial Release #
Core Features
- USB thermal printer communication support for Android devices
- Support for CSN Printer SDK integration
- Real-time printer event streaming (connection, disconnection, print completion)
Device Management
listDevices()- List all connected USB devices with vendor/product IDsisSupported()- Check if USB Host mode is supported on the devicehasPermission(deviceName)- Verify USB device access permissionsrequestPermission(deviceName)- Request USB device access with system dialogconnect(deviceName)- Connect to printer by device nameconnectByIds(vendorId, productId)- Connect to printer by vendor and product IDsdisconnect()- Disconnect from the printerisConnected()- Check current connection status
Printing Functions
printText(text, alignment, cutPaper)- Print simple text with alignment optionsprintTextFormatted()- Print text with advanced formatting:- Font attributes (bold, underline, double width, double height)
- Font size control (width and height)
- Font type selection
- Text alignment (left, center, right)
printPicture(imageBytes, alignment, width, cutPaper)- Print images from byte arrayprintPictureBase64(base64Image, alignment, cutPaper)- Print images from Base64 string
Paper Control
cutPaper()- Full paper cutpartialCutPaper()- Partial paper cutfeedPaper(lines)- Feed paper by specified number of lines
Hardware Control
openCashDrawer(pin, onTime)- Open cash drawer with configurable pin and durationbeep(times, duration)- Emit beeps with configurable count and duration
Testing & Utilities
runTest(iterations)- Run connection and printing stress testsgetPlatformVersion()- Get Android platform version
Models & Types
UsbDeviceInfo- USB device information data classPrintResult- Print operation result with success status and result codePrinterEvent- Event model for printer state changesPrinterEventType- Enum for event types (onOpen, onOpenFailed, onClose, onPrintComplete)TextAlignment- Enum for text alignment (left, center, right)FontAttributes- Font styling configuration class
Event Stream
printerEvents- Stream for real-time printer events monitoring
Example App
- Complete example application demonstrating all features
- Interactive UI with device selection
- Real-time status updates
- All printing and control functions
Technical Details #
- Minimum Android SDK: API 12 (Android 3.1 - Honeycomb MR1)
- Uses Activity-aware plugin architecture for proper USB permission handling
- Implements CSNIOCallBack for printer state management
- Thread-safe operations with ExecutorService
- BroadcastReceiver integration for USB permission requests
Platform Support #
- ✅ Android
- ❌ iOS (not supported - USB printing not available on iOS)