sunmi_flutter_helper 0.0.7 copy "sunmi_flutter_helper: ^0.0.7" to clipboard
sunmi_flutter_helper: ^0.0.7 copied to clipboard

Flutter plugin for Sunmi V2s Plus printers and scanners.

Sunmi Flutter Helper Plugin #

A Flutter plugin to print rich receipts via Sunmi printers. Supports text, QR, barcode, image, table columns, divider lines, and NFC/Scanner streams.


๐Ÿš€ Getting Started #

1. Add dependency #

dependencies:
  sunmi_flutter_helper: ^0.0.2

2. Android Permissions (Optional) #

<uses-permission android:name="android.permission.BLUETOOTH" />

โœ… Printer Connection Check #

bool isConnected = await SunmiFlutterHelper.isPrinterConnected();

๐Ÿ–จ Print Text #

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)

๐Ÿ“ฆ Print QR Code #

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

๐Ÿงพ Print Barcode #

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"

๐Ÿ–ผ Print Image #

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"

โž– Print Divider Line #

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)

๐Ÿ” Barcode/QR Scanner Stream #

SunmiFlutterHelper.scanStream.listen((code) {
  print("Scanned Code: $code");
});

๐Ÿ“ถ NFC Reader Stream #

SunmiFlutterHelper.nfcStream.listen((data) {
  print("NFC Data: $data");
});

๐Ÿ›  Requirements #

  • Flutter 3.0+
  • Android 11+
  • Only for Sunmi Android devices

๐Ÿ‘จโ€๐Ÿ’ป Maintainer #

4Brains Technologies
๐Ÿ”— https://www.4brains.in
๐Ÿ“ง contact@4brains.in