sunmi_flutter_helper 0.0.2
sunmi_flutter_helper: ^0.0.2 copied to clipboard
Flutter plugin for Sunmi V2s Plus printers and scanners.
Sunmi Flutter Helper Plugin #
A Flutter plugin for printing rich thermal receipts using the Sunmi V2s Plus printer via the official PrinterX Java SDK.
Supports:
- Text (with styling)
- QR Code
- Barcode
- Bitmap image
- Dividing lines (solid, dotted, empty)
- Column layout (e.g. item, qty, price)
๐ Getting Started #
1. Add to pubspec.yaml #
dependencies:
sunmi_flutter_helper: ^0.0.2
2. Android Setup #
Ensure your app is running on a Sunmi device with Android. Add permissions if required:
<uses-permission android:name="android.permission.BLUETOOTH" />
3. Assets (Optional - for image printing) #
flutter:
assets:
- assets/images/logo.jpg
๐จ Features & Usage #
โ Check Printer Connection #
bool isConnected = await SunmiFlutterHelper.isPrinterConnected();
๐ Print Text #
await SunmiFlutterHelper.printText({
'text': "Welcome to Sunmi",
'align': "center",
'bold': true,
'underline': true,
'size': 18,
});
๐ฆ Print QR Code #
await SunmiFlutterHelper.printQrCode({
'qrText': 'https://yourdomain.com',
'align': 'center',
'width': 250,
'height': 250,
});
๐งพ Print Barcode #
await SunmiFlutterHelper.printBarcode({
"data": "123456789012",
"align": "center",
"width": 300,
"height": 100,
"readable": "TWO" // Options: ONE, TWO, THREE
});
๐ผ Print Image #
Uint8List bytes = await loadImageAsset('assets/images/logo.jpg');
await SunmiFlutterHelper.printImage({
"image": bytes,
"align": "center",
"width": 384 // auto-maintains aspect ratio
});
๐งฑ Print Dividing Line #
await SunmiFlutterHelper.printLine({'type': 'solid', 'height': 4});
await SunmiFlutterHelper.printLine({'type': 'dotted', 'height': 2});
await SunmiFlutterHelper.printLine({'type': 'empty', 'height': 10});
๐ Print Table Columns #
await SunmiFlutterHelper.printColumns({
'texts': ['Item', 'Qty', 'Amount'],
'weights': [3, 1, 2],
'align': 'right'
});
๐ Full Example #
Check example/main.dart for a complete working sample.
๐ง Methods #
| Method | Description |
|---|---|
isPrinterConnected() |
Check printer connection |
printText({...}) |
Print styled text |
printQrCode({...}) |
Print QR code |
printBarcode({...}) |
Print barcode |
printImage({...}) |
Print image from Uint8List |
printLine({...}) |
Print margin/dividing line |
printColumns({...}) |
Print table row |
๐ Requirements #
- Android 11+
- Tested on: Sunmi V2s Plus
- Flutter 3.0+
๐จโ๐ป Maintainer #
4Brains Technologies
https://www.4brains.in
For support or customization: [email protected]
๐ License #
MIT License