printBarCode static method
Future<void>
printBarCode(
- String data, {
- SunmiBarcodeType barcodeType = SunmiBarcodeType.CODE128,
- int height = 162,
- int width = 2,
- SunmiBarcodeTextPos textPosition = SunmiBarcodeTextPos.TEXT_ABOVE,
printBarCode
With this method you can print a barcode with any type described below or in the enum section
Implementation
static Future<void> printBarCode(String data,
{SunmiBarcodeType barcodeType = SunmiBarcodeType.CODE128,
int height = 162,
int width = 2,
SunmiBarcodeTextPos textPosition = SunmiBarcodeTextPos.TEXT_ABOVE}) async {
int codeType = 8;
int localTextPosition = 8;
switch (barcodeType) {
case SunmiBarcodeType.UPCA:
codeType = 0;
break;
case SunmiBarcodeType.UPCE:
codeType = 1;
break;
case SunmiBarcodeType.JAN13:
codeType = 2;
break;
case SunmiBarcodeType.JAN8:
codeType = 3;
break;
case SunmiBarcodeType.CODE39:
codeType = 4;
break;
case SunmiBarcodeType.ITF:
codeType = 5;
break;
case SunmiBarcodeType.CODABAR:
codeType = 6;
break;
case SunmiBarcodeType.CODE93:
codeType = 7;
break;
case SunmiBarcodeType.CODE128:
codeType = 8;
break;
}
switch (textPosition) {
case SunmiBarcodeTextPos.NO_TEXT:
localTextPosition = 0;
break;
case SunmiBarcodeTextPos.TEXT_ABOVE:
localTextPosition = 1;
break;
case SunmiBarcodeTextPos.TEXT_UNDER:
localTextPosition = 2;
break;
case SunmiBarcodeTextPos.BOTH:
localTextPosition = 3;
break;
}
Map<String, dynamic> arguments = <String, dynamic>{
"data": data,
'barcodeType': codeType,
'textPosition': localTextPosition,
'width': width,
'height': height
};
await _channel.invokeMethod("PRINT_BARCODE", arguments);
}