printQRCode static method

Future<bool> printQRCode(
  1. String data, {
  2. int size = 200,
  3. Alignment alignment = Alignment.center,
})

Print a QR code.

Convenience method for printing a QR code with customizable size.

  • data: Content to encode in the QR code
  • size: Size of the QR code (width and height)
  • alignment: QR code alignment (left, center, right)

Returns true if printing was successful.

Implementation

static Future<bool> printQRCode(
  String data, {
  int size = 200,
  Alignment alignment = Alignment.center,
}) async {
  // QR codes typically have a 1:1 aspect ratio, so use size for both dimensions
  return await printBarcode(
    data,
    BarcodeType.qrCode,
    height: size,
    width: 1, // For QR codes, width is module size
    alignment: alignment,
    textPosition:
        BarcodeTextPosition.none, // QR codes don't have human-readable text
  );
}