printImageBytes static method

Future<bool> printImageBytes(
  1. Uint8List imageBytes, {
  2. int width = 0,
  3. Alignment alignment = Alignment.centerLeft,
})

Print an image from bytes.

  • imageBytes: Raw image data as bytes
  • width: Width to resize the image (0 = printer default)
  • alignment: Image alignment (left, center, right)

Returns true if printing was successful.

Implementation

static Future<bool> printImageBytes(
  Uint8List imageBytes, {
  int width = 0,
  Alignment alignment = Alignment.centerLeft,
}) async {
  try {
    return await PrinterCore.printImageBytes(
      imageBytes,
      width: width,
      alignment: TextFormatter.convertAlignment(alignment),
    );
  } catch (e) {
    print('Error printing image bytes: $e');
    return false;
  }
}