sunmi_flutter_helper 0.0.9
sunmi_flutter_helper: ^0.0.9 copied to clipboard
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