sunmi_flutter_helper 0.0.2 copy "sunmi_flutter_helper: ^0.0.2" to clipboard
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