printBarCode method

  1. @override
Future<void> printBarCode(
  1. IminBarcodeType barCodeType,
  2. String barCodeContent, {
  3. IminBarCodeStyle? style,
})
override

Implementation

@override
Future<void> printBarCode(IminBarcodeType barCodeType, String barCodeContent,
    {IminBarCodeStyle? style}) async {
  Map<String, dynamic> arguments = <String, dynamic>{
    "data": barCodeContent,
    "type": barCodeType.type
  };
  if (style != null) {
    if (style.align != null &&
        style.height != null &&
        style.width != null &&
        style.position != null) {
      arguments.putIfAbsent('width', () => style.width);
      arguments.putIfAbsent('align', () => style.align?.index);
      arguments.putIfAbsent('height', () => style.height);
      arguments.putIfAbsent('position', () => style.position?.position);
    } else {
      if (style.align != null) {
        arguments.putIfAbsent('align', () => style.align?.index);
      }
      if (style.height != null) {
        await setBarCodeHeight(style.height!);
      }
      if (style.width != null) {
        await setBarCodeWidth(style.width!);
      }
      if (style.position != null) {
        await setBarCodeContentPrintPos(style.position!);
      }
    }
  }
  logger.d('printBarCode: $arguments');
  await methodChannel.invokeMethod<void>('printBarCode', arguments);
}