printSelected method

Future<void> printSelected(
  1. BuildContext context
)

Sends the print to the system print dialog.

Implementation

Future<void> printSelected(BuildContext context) async {
  final printRequest = request(context);
  final bytes = await PrintPdfRenderer.render(printRequest);
  final format = printRequest.paper;
  await Printing.layoutPdf(
    name: _fileName,
    // Labels and signs carry their own page size: the document is not
    // re-laid out on the printer format, or labels drift off the sheet.
    format: PdfPageFormat(
      format.pageWidthMm * PdfPageFormat.mm,
      format.pageHeightMm * PdfPageFormat.mm,
    ),
    dynamicLayout: false,
    onLayout: (_) async => bytes,
  );
}