A Flutter plugin to print rich receipts via Sunmi printers. Supports text, QR, barcode, image, table columns, divider lines, and NFC/Scanner streams.
dependencies:
sunmi_flutter_helper: ^0.0.2
2. Android Permissions (Optional) #
<uses-permission android:name="android.permission.BLUETOOTH" />
bool isConnected = await SunmiFlutterHelper.isPrinterConnected();
await SunmiFlutterHelper.printText(
text: "Welcome",
align: "center",
bold: true,
underline: true,
size: 18,
);
| Parameter |
Type |
Required |
Description |
text |
String |
โ
|
The text to print |
align |
String |
โ |
"left", "center", or "right" |
bold |
bool |
โ |
Bold style |
underline |
bool |
โ |
Underline text |
size |
int |
โ |
Font size (default is 16) |
await SunmiFlutterHelper.printQrCode(
qrText: "https://4brains.in",
align: "center",
width: 200,
height: 200,
);
| Parameter |
Type |
Required |
Description |
qrText |
String |
โ
|
Data to encode in the QR code |
align |
String |
โ |
"left", "center", or "right" |
width |
int |
โ |
Width in pixels |
height |
int |
โ |
Height in pixels |
await SunmiFlutterHelper.printBarcode(
data: "123456789012",
align: "center",
width: 300,
height: 100,
readable: "TWO",
);
| Parameter |
Type |
Required |
Description |
data |
String |
โ
|
Barcode data |
align |
String |
โ |
"left", "center", or "right" |
width |
int |
โ |
Width in pixels |
height |
int |
โ |
Height in pixels |
readable |
String |
โ |
Human-readable: "ONE", "TWO", "THREE" |
final bytes = await loadImageAsset("assets/logo.jpg");
await SunmiFlutterHelper.printImage(
image: bytes,
align: "center",
width: 384,
threshold: 200,
);
| Parameter |
Type |
Required |
Description |
image |
Uint8List |
โ
|
Image byte data |
align |
String |
โ |
"left", "center", or "right" |
width |
int |
โ |
Target width |
height |
int |
โ |
Target height |
threshold |
int |
โ |
Binarization threshold (default 200) |
๐ Print Table Columns #
await SunmiFlutterHelper.printColumns(
texts: ['Item', 'Qty', 'Price'],
weights: [3, 1, 2],
align: "right",
);
| Parameter |
Type |
Required |
Description |
texts |
List |
โ
|
List of column texts |
weights |
List |
โ
|
Width weight for each column |
align |
String |
โ |
"left", "center", or "right" |
await SunmiFlutterHelper.printLine(
type: 'solid',
height: 4,
);
| Parameter |
Type |
Required |
Description |
type |
String |
โ
|
"solid", "dotted", or "empty" |
height |
int |
โ |
Height of the line (default 24 px) |
SunmiFlutterHelper.scanStream.listen((code) {
print("Scanned Code: $code");
});
SunmiFlutterHelper.nfcStream.listen((data) {
print("NFC Data: $data");
});
- Flutter 3.0+
- Android 11+
- Only for Sunmi Android devices
๐จโ๐ป Maintainer #
4Brains Technologies
๐ https://www.4brains.in
๐ง contact@4brains.in