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
| Name | Type | Description |
|---|---|---|
text | String | Text to print (required) |
align | String | Alignment: "left", "center", "right" |
bold | bool | Bold text |
underline | bool | Underlined text |
size | int | Font size (default: 16) |
widthRatio | int | Width ratio (default: 1) |
heightRatio | int | Height ratio (default: 1) |
letterSpace | int | Space between letters |
strikethrough | bool | Strike-through text |
🔲 Print QR Code
await SunmiFlutterHelper.printQrCode(
qrText: "https://yourdomain.com",
align: "center",
width: 250,
height: 250,
);
Parameters
| Name | Type | Description |
|---|---|---|
qrText | String | Text to encode in QR (required) |
align | String | Alignment: "left", "center", "right" |
width | int | Width in pixels |
height | int | Height in pixels |
dot | int | Dot size (1-8) |
errorLevel | String | QR error correction level: L, M, Q, H |
🧾 Print Barcode
await SunmiFlutterHelper.printBarcode(
data: "123456789012",
align: "center",
width: 300,
height: 100,
);
Parameters
| Name | Type | Description |
|---|---|---|
data | String | Barcode content (required) |
align | String | "left", "center", "right" |
width | int | Width in pixels |
height | int | Height in pixels |
readable | String | Human-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
| Name | Type | Description |
|---|---|---|
image | Uint8List | Image bytes (required) |
align | String | "left", "center", "right" |
width | int | Width in pixels |
height | int | Height in pixels |
threshold | int | Black & white threshold (optional) |
📊 Print Columns
await SunmiFlutterHelper.printColumns(
texts: ['Item', 'Qty', 'Price'],
weights: [3, 1, 2],
align: 'left',
);
Parameters
| Name | Type | Description |
|---|---|---|
texts | List | Column texts (required) |
weights | List | Column width weights (required) |
align | String | "left", "center", "right" |
➖ Print Line
await SunmiFlutterHelper.printLine(type: "dotted", height: 3);
Parameters
| Name | Type | Description |
|---|---|---|
type | String | Type of line: "solid", "dotted", "empty" |
height | int | Height 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