printCenteredBarcode static method

Future<bool> printCenteredBarcode({
  1. required String data,
  2. required BarcodeType type,
  3. int height = 200,
  4. int width = 6,
  5. BarcodeTextPosition textPosition = BarcodeTextPosition.below,
  6. int? printerWidth,
})

Print a centered barcode with default settings.

Convenience method for printing a barcode with center alignment.

  • data: Content to encode in the barcode
  • type: Barcode type (CODE128, QR, etc.)
  • height: Barcode height in dots
  • width: Barcode module width in dots
  • textPosition: Position of human-readable text
  • printerWidth: Printer width in dots

Returns true if printing was successful.

Implementation

static Future<bool> printCenteredBarcode({
  required String data,
  required BarcodeType type,
  int height = 200,
  int width = 6,
  BarcodeTextPosition textPosition = BarcodeTextPosition.below,
  int? printerWidth,
}) async {
  // Always center for this function
  const alignment = Alignment.center;

  // Use the existing barcode print function with center alignment
  return await printBarcode(
    data,
    type,
    height: height,
    width: width,
    alignment: alignment,
    textPosition: textPosition,
  );
}