sunmi_flutter_helper 0.0.9

SDKflutter
Platformandroid

Flutter plugin for printing and scanning on Sunmi POS devices using PrinterX SDK.

Sunmi Flutter Helper

A Flutter plugin for printing rich thermal receipts on Sunmi POS devices with support for text, QR codes, barcodes, images, and more using the official PrinterX SDK.


🛠 Features

  • Print Text (with style)
  • Print QR Code
  • Print Barcode
  • Print Image
  • Print Table Columns
  • Print Lines (solid, dotted, empty)
  • NFC & Scanner Stream Support

📦 Installation

Add to your pubspec.yaml:

dependencies:
  sunmi_flutter_helper: ^0.0.8

✅ Printer Connection

bool isConnected = await SunmiFlutterHelper.isPrinterConnected();

📝 Print Text

await SunmiFlutterHelper.printText(
  text: "ABCD Company",
  align: "center",
  bold: true,
  underline: true,
  size: 16,
);

Parameters

NameTypeDescription
textStringText to print (required)
alignStringAlignment: "left", "center", "right"
boldboolBold text
underlineboolUnderlined text
sizeintFont size (default: 16)
widthRatiointWidth ratio (default: 1)
heightRatiointHeight ratio (default: 1)
letterSpaceintSpace between letters
strikethroughboolStrike-through text

🔲 Print QR Code

await SunmiFlutterHelper.printQrCode(
  qrText: "https://yourdomain.com",
  align: "center",
  width: 250,
  height: 250,
);

Parameters

NameTypeDescription
qrTextStringText to encode in QR (required)
alignStringAlignment: "left", "center", "right"
widthintWidth in pixels
heightintHeight in pixels
dotintDot size (1-8)
errorLevelStringQR error correction level: L, M, Q, H

🧾 Print Barcode

await SunmiFlutterHelper.printBarcode(
  data: "123456789012",
  align: "center",
  width: 300,
  height: 100,
);

Parameters

NameTypeDescription
dataStringBarcode content (required)
alignString"left", "center", "right"
widthintWidth in pixels
heightintHeight in pixels
readableStringHuman-readable mode: ONE, TWO, or THREE

🖼 Print Image

Uint8List imageBytes = await loadImageAsset('assets/logo.jpg');
await SunmiFlutterHelper.printImage(
  image: imageBytes,
  align: 'center',
  width: 384
);

Parameters

NameTypeDescription
imageUint8ListImage bytes (required)
alignString"left", "center", "right"
widthintWidth in pixels
heightintHeight in pixels
thresholdintBlack & white threshold (optional)

📊 Print Columns

await SunmiFlutterHelper.printColumns(
  texts: ['Item', 'Qty', 'Price'],
  weights: [3, 1, 2],
  align: 'left',
);

Parameters

NameTypeDescription
textsListColumn texts (required)
weightsListColumn width weights (required)
alignString"left", "center", "right"

➖ Print Line

await SunmiFlutterHelper.printLine(type: "dotted", height: 3);

Parameters

NameTypeDescription
typeStringType of line: "solid", "dotted", "empty"
heightintHeight of the line

📡 Streams

SunmiFlutterHelper.scanStream.listen((code) {
  print("Scanned: $code");
});

SunmiFlutterHelper.nfcStream.listen((nfcData) {
  print("NFC: $nfcData");
});

✅ Requirements

  • Flutter 3.0+
  • Android 11+ on Sunmi device
  • Permissions: (Optional)
    <uses-permission android:name="android.permission.NFC" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    

🧪 Example App

See /example folder for a full working app.


👨‍💻 Maintainer

4Brains Technologies
https://www.4brains.in
For support: contact@4brains.in


📄 License

MIT