PdfViewer constructor

const PdfViewer({
  1. Key? key,
  2. required String pdfPath,
  3. bool initialSidebarOpen = false,
  4. double sidebarWidth = 160,
  5. double thumbnailHeight = 150,
  6. Color sidebarBackgroundColor = Colors.grey,
  7. BoxDecoration? selectedPageDecoration,
  8. bool showZoomHint = true,
  9. int initialPage = 1,
  10. bool showPageIndicator = true,
  11. void onPageChanged(
    1. int page
    )?,
  12. PdfSemanticLabels semanticLabels = const PdfSemanticLabels(),
})

Creates a PdfViewer widget.

The pdfPath parameter is required and should point to a valid PDF file. It can be either a URL (starting with http:// or https://) or an asset path.

The initialSidebarOpen parameter determines whether the thumbnail sidebar is initially visible.

The sidebarWidth parameter sets the width of the thumbnail sidebar.

The thumbnailHeight parameter sets the height of each thumbnail in the sidebar.

The sidebarBackgroundColor parameter sets the background color of the sidebar.

The selectedPageDecoration parameter sets the decoration for the selected page thumbnail.

The showZoomHint parameter determines whether to show an animated hint indicating that the user can pinch to zoom. Defaults to true.

The initialPage parameter sets the page shown on first open. Defaults to 1.

The showPageIndicator parameter shows a "current / total" overlay. Defaults to true.

The onPageChanged callback is called whenever the user navigates to a new page.

The semanticLabels parameter allows customising the labels announced by screen readers (VoiceOver / TalkBack). Defaults to English labels.

Implementation

const PdfViewer({
  super.key,
  required this.pdfPath,
  this.initialSidebarOpen = false,
  this.sidebarWidth = 160,
  this.thumbnailHeight = 150,
  this.sidebarBackgroundColor = Colors.grey,
  this.selectedPageDecoration,
  this.showZoomHint = true,
  this.initialPage = 1,
  this.showPageIndicator = true,
  this.onPageChanged,
  this.semanticLabels = const PdfSemanticLabels(),
});