onPrint method

  1. @override
Future<void> onPrint()
override

Implementation

@override
Future<void> onPrint() async {
  if (fileBytes == null) return;

  final pdf = pw.Document();
  final image = pw.MemoryImage(fileBytes!);

  pdf.addPage(
    pw.Page(
      pageFormat: PdfPageFormat.a4,
      build: (context) => pw.Center(child: pw.Image(image)),
    ),
  );

  await Printing.layoutPdf(onLayout: (format) => pdf.save());
}