PdfPreview.builder constructor

const PdfPreview.builder({
  1. Key? key,
  2. required LayoutCallback build,
  3. PdfPageFormat? initialPageFormat,
  4. bool allowPrinting = true,
  5. bool allowSharing = true,
  6. double? maxPageWidth,
  7. bool canChangePageFormat = true,
  8. bool canChangeOrientation = true,
  9. bool canDebug = true,
  10. List<Widget>? actions,
  11. Map<String, PdfPageFormat> pageFormats = _defaultPageFormats,
  12. Widget onError(
    1. BuildContext context,
    2. Object error
    )?,
  13. void onPrinted(
    1. BuildContext context
    )?,
  14. void onPrintError(
    1. BuildContext context,
    2. dynamic error
    )?,
  15. void onShared(
    1. BuildContext context
    )?,
  16. Decoration? scrollViewDecoration,
  17. Decoration? pdfPreviewPageDecoration,
  18. String? pdfFileName,
  19. bool useActions = true,
  20. List<int>? pages,
  21. bool dynamicLayout = true,
  22. String? shareActionExtraBody,
  23. String? shareActionExtraSubject,
  24. List<String>? shareActionExtraEmails,
  25. EdgeInsets? previewPageMargin,
  26. EdgeInsets? padding,
  27. bool shouldRepaint = false,
  28. Widget? loadingWidget,
  29. ValueChanged<PdfPageFormat>? onPageFormatChanged,
  30. double? dpi,
  31. PdfActionBarTheme actionBarTheme = const PdfActionBarTheme(),
  32. required CustomPdfPagesBuilder pagesBuilder,
  33. bool enableScrollToPage = false,
  34. ValueChanged<bool>? onZoomChanged,
})

Build a custom layout.

PdfPreview.builder(
  build: (format) => _generatePdf(format, title),
  pagesBuilder: (context, pages) => SingleChildScrollView(
    child: Wrap(
      spacing: 8,
      runSpacing: 8,
      children: [
        for (final page in pages)
          Container(
            color: Colors.white,
            child: Image(
              image: page.image,
              width: 300,
            ),
          )
      ],
    ),
  ),
)

Implementation

const PdfPreview.builder({
  Key? key,
  required this.build,
  this.initialPageFormat,
  this.allowPrinting = true,
  this.allowSharing = true,
  this.maxPageWidth,
  this.canChangePageFormat = true,
  this.canChangeOrientation = true,
  this.canDebug = true,
  this.actions,
  this.pageFormats = _defaultPageFormats,
  this.onError,
  this.onPrinted,
  this.onPrintError,
  this.onShared,
  this.scrollViewDecoration,
  this.pdfPreviewPageDecoration,
  this.pdfFileName,
  this.useActions = true,
  this.pages,
  this.dynamicLayout = true,
  this.shareActionExtraBody,
  this.shareActionExtraSubject,
  this.shareActionExtraEmails,
  this.previewPageMargin,
  this.padding,
  this.shouldRepaint = false,
  this.loadingWidget,
  this.onPageFormatChanged,
  this.dpi,
  this.actionBarTheme = const PdfActionBarTheme(),
  required CustomPdfPagesBuilder pagesBuilder,
  this.enableScrollToPage = false,
  this.onZoomChanged,
})  : _pagesBuilder = pagesBuilder,
      super(key: key);