printQrCode method

  1. @override
Future<void> printQrCode(
  1. String data, {
  2. IminQrCodeStyle? qrCodeStyle,
})
override

Implementation

@override
Future<void> printQrCode(String data, {IminQrCodeStyle? qrCodeStyle}) async {
  Map<String, dynamic> arguments = <String, dynamic>{};
  if (qrCodeStyle != null) {
    if (qrCodeStyle.align != null &&
        qrCodeStyle.qrSize != null &&
        qrCodeStyle.errorCorrectionLevel != null) {
      arguments.putIfAbsent("alignment", () => qrCodeStyle.align?.index);
      arguments.putIfAbsent("qrSize", () => qrCodeStyle.qrSize!);
      arguments.putIfAbsent(
          "level", () => qrCodeStyle.errorCorrectionLevel?.level);
      if (qrCodeStyle.leftMargin != null) {
        await setLeftMargin(qrCodeStyle.leftMargin!);
      }
    } else {
      if (qrCodeStyle.align != null) {
        arguments.putIfAbsent("alignment", () => qrCodeStyle.align?.index);
      }
      if (qrCodeStyle.qrSize != null) {
        await setQrCodeSize(qrCodeStyle.qrSize!);
      }

      if (qrCodeStyle.leftMargin != null) {
        await setLeftMargin(qrCodeStyle.leftMargin!);
      }
      if (qrCodeStyle.errorCorrectionLevel != null) {
        await setQrCodeErrorCorrectionLev(qrCodeStyle.errorCorrectionLevel!);
      }
    }
  }
  arguments.putIfAbsent("data", () => data);
  await methodChannel.invokeMethod<void>('printQrCode', arguments);
}