flutter_sunmi_printer_plus 0.0.1 flutter_sunmi_printer_plus: ^0.0.1 copied to clipboard
This plugin for Sunmi devices where you can print text, image, table, barcode and QR code.
flutter_sunmi_printer_plus #
This is plugin inspired by SunmiPrinterDemo
Platform Support #
This plugin works only on android
Usage #
To use this plugin, add flutter_sunmi_printer_plus
as a dependency in your pubspec.yaml file
What this package do #
- ✅ Print text with style (font size,bold or not,alignment,..)
- ✅ Print image (you can set alignment)
- ✅ Print table
- ✅ Print qrcode (with stye)
- ✅ Print barcode(with style)
- ✅ Jump n-lines
- ✅ Cut paper
Example #
Import the library.
import 'package:flutter_sunmi_printer_plus/flutter_sunmi_printer_plus.dart';
Then invoke the static initPrinter
method to initiate sunmi printer .
@override
void initState() {
super.initState();
Future.delayed(Duration.zero, () async {
try {
isConnected = await SunmiPrinter.initPrinter() ?? false;
setState(() {});
} catch (err) {
errorMessage = err.toString();
}
setState(() {});
});
}
Print text
await SunmiPrinter.printText(
content: "Test String",
style: SunmiStyle(
fontSize: 20,
isUnderLine: true,
bold: false,
align: SunmiPrintAlign.LEFT));
Print image
await SunmiPrinter.printImage(image: bytes, align: SunmiPrintAlign.CENTER); // bytes as Uint8List
Print table
await SunmiPrinter.printTable(cols: [
ColumnMaker(text:"test#1" ,align:SunmiPrintAlign.LEFT ,width:5),
ColumnMaker(text:"test#2" ,align:SunmiPrintAlign.LEFT ,width: 5),
]);
Print barcode
await SunmiPrinter.printBarCode(data: "1234567890",height: 50,width: 2,textPosition: SunmiBarcodeTextPos.TEXT_UNDER,barcodeType:SunmiBarcodeType.CODE128,align:SunmiPrintAlign.CENTER );
Print qrcode
await SunmiPrinter.printQr(data: "https://twitter.com/wojoodtech",align:SunmiPrintAlign.CENTER,size: 5);
See the main.dart
in the example
for a complete example.