printImageWithCaption static method
Print an image with a caption.
Prints an image followed by a centered caption text.
imagePath: Path to the image filecaption: Text caption to print below the imagewidth: Width to resize the image (0 = printer default)alignment: Image alignment (left, center, right)fontSize: Font size for the caption text
Returns true if printing was successful.
Implementation
static Future<bool> printImageWithCaption(
String imagePath, {
required String caption,
int width = 0,
Alignment alignment = Alignment.center,
double fontSize = 18,
}) async {
try {
// First print the image
final imageResult = await printImage(
imagePath,
width: width,
alignment: alignment,
);
if (!imageResult) {
return false;
}
// Then print the caption
final captionResult = await PrinterText.printCenteredText(
text: caption,
fontSize: fontSize,
);
return captionResult;
} catch (e) {
print('Error printing image with caption: $e');
return false;
}
}