cpcl_esc_printer 0.2.0
cpcl_esc_printer: ^0.2.0 copied to clipboard
Flutter BLE thermal printer plugin with CPCL / ESC-POS / TSPL builders — text, barcode, QR, tables, images, plus optional Material scan/debug UI.
0.2.0 #
- Add
TsplBuilder— a TSPL / TSPL2 (TSC) label command builder:SIZE/GAP/BLINE/DIRECTION/DENSITY/SPEED/CODEPAGEsetup,text,barcode(14 symbologies),qrcode,box/bar/hLine/vLine,image(BITMAP, byte-inverted soMonoBitmap1=black maps correctly), paper controls (feed/backFeed/formFeed/home),sound,cut,cls,raw/rawLineescape hatches, andbuild({copies, sets}). Text is routed through the pluggableTextEncoder(GBK for Chinese); lines use CRLF.
0.1.1 #
- Docs: use absolute GitHub URLs for the language switch link and sponsor images so they render on pub.flutter-io.cn (relative paths only worked on GitHub).
0.1.0 #
Initial release.
Connectivity #
- BLE connect / disconnect / auto-reconnect built on
flutter_blue_plus 1.36.8(the last BSD-3 / free release before the 2.0.0 commercial-license switch). Supports Android / iOS / macOS / Linux / Web. - MTU-aware chunking:
writeRawchunks using the connection's negotiated MTU (Android ~512, iOS/macOS ~135-255) with a fixed fallback — big speedup for image / long-label printing.PrinterProfile.autoMtu(default true) andPrinterManager.negotiatedMtu. - Per-print completion detection via the notify characteristic (fixed-delay fallback when no notify characteristic is present). Serialised write queue so multi-label jobs never interleave.
Command builders #
CpclBuilder— CPCL label commands: text / font sizes, bold, magnify, rotation,justify,underline,inverseLine,pattern,contrast,speed,serialCount,pageWidth,beep,cut, gap/bar sensing (gapSense/barSense/barSenseLeft),charSpacing,encoding/country,scaleText, barcodes (UPCA / EAN / CODE39 / 93 / 128 / CODABAR / ITF / … + vertical), QR /pdf417/datamatrix, HRI text,prefeed/postfeed,pace/wait, watermark (background/bkText),reprint, multi-fontconcatandmultiline,graphics/image(EG bitmap) and a bordered gridtable(). (lineSpacingis deprecated —SETSPis character spacing; usecharSpacing.)EscBuilder— ESC/POS receipt commands: text, alignment, font sizes, positioning (absolutePosition/relativePosition/leftMargin/printAreaWidth),printMode,reverse,rotate90,upsideDown,doubleStrike,selectFont,charSpacing, Chinese modes, code tables,codePage(GBK / Big5), barcode config + generalizedbarcode(GS k function B),barcode128, QR code (qrcodeandqrcodeGsk), columns, monospacetable(),raster/image/imageBitImage(GS v 0 and ESC * 33 modes),cut/cutGsV, black-mark feeds (feedToRightMark/feedToLeftMark),cashDrawer/realtimeDrawerPulse,buzzer, page mode (pageMode/standardMode/pageArea/pageDirection/printPage/pageAbsoluteVertical/pageRelativeVertical), peripheral/panel controls (selectPeripheral/panelKeys/chineseCodeFormat/userDefinedCharset/cancelUserChar), and status queries (realtimeStatusDLE EOT /transmitStatusGS r /realtimeRequest/autoStatusBack/transmitId/deviceStatuswithDeviceStatus.parse— replies on the notify characteristic).- Escape hatches for vendor-specific commands:
CpclBuilder.raw/rawLineandEscBuilder.raw/rawText— wrap your own chainable helpers via a Dartextension. Builders are transport-agnostic:build()bytes can be sent over BLE, classic SPP, USB, etc. - Pluggable
TextEncoder(defaults to UTF-8; plug in GBK for Chinese printers). - Dependency-free
MonoBitmap(RGBA / grayscale → 1-bit, optional Floyd–Steinberg dithering). PNG/JPG decoding is delegated to the optionalimagepackage, not depended on.
Configuration & UI #
PrinterProfile— configurable service / write / notify UUIDs with a built-ingeneric(Nordic-UART) preset andautoDetect. Vendor-specific characteristics are handled via the debug page's live picker rather than shipped presets. Tunables:autoMtu,mtu,chunkDelayMs,printTimeoutMs,fallbackDelayMs,writeWithoutResponse.PrinterManagersingleton exposing scan/connect/write plusnegotiatedMtu,connectedDeviceId/connectedDeviceName, and the resolvedboundServiceUuid/boundWriteUuid/boundNotifyUuid(noflutter_blue_plustypes leaked to callers).- Optional Material
PrinterScannerPageandPrinterDebugPage(decoupled from GetX / flustars / smart_dialog). The debug page lists services/characteristics, lets you pick and apply the write/notify pair live, copies UUIDs, and prints font / label / receipt / image samples. - Example app demonstrating runtime permissions (
permission_handler) and persistence + auto-reconnect (shared_preferences) — both example-only; the plugin itself depends only onflutter_blue_plus.