SfPdfViewer.asset constructor

SfPdfViewer.asset(
  1. String name, {
  2. Key? key,
  3. AssetBundle? bundle,
  4. bool canShowScrollHead = true,
  5. double pageSpacing = 4,
  6. PdfViewerController? controller,
  7. PdfZoomLevelChangedCallback? onZoomLevelChanged,
  8. bool canShowPageLoadingIndicator = true,
  9. bool canShowScrollStatus = true,
  10. PdfPageChangedCallback? onPageChanged,
  11. PdfDocumentLoadedCallback? onDocumentLoaded,
  12. bool enableDoubleTapZooming = true,
  13. bool enableTextSelection = true,
  14. PdfTextSelectionChangedCallback? onTextSelectionChanged,
  15. PdfHyperlinkClickedCallback? onHyperlinkClicked,
  16. PdfDocumentLoadFailedCallback? onDocumentLoadFailed,
  17. bool enableDocumentLinkAnnotation = true,
  18. bool canShowPaginationDialog = true,
  19. Offset initialScrollOffset = Offset.zero,
  20. double initialZoomLevel = 1,
  21. double maxZoomLevel = 3,
  22. PdfInteractionMode interactionMode = PdfInteractionMode.selection,
  23. PdfScrollDirection scrollDirection = PdfScrollDirection.vertical,
  24. PdfPageLayoutMode pageLayoutMode = PdfPageLayoutMode.continuous,
  25. Color currentSearchTextHighlightColor = const Color.fromARGB(80, 249, 125, 0),
  26. Color otherSearchTextHighlightColor = const Color.fromARGB(50, 255, 255, 1),
  27. String? password,
  28. bool canShowPasswordDialog = true,
  29. bool canShowHyperlinkDialog = true,
  30. bool enableHyperlinkNavigation = true,
})

Creates a widget that displays the PDF document obtained from an asset bundle.

class MyAppState extends State<MyApp>{
@override
void initState() {
  super.initState();
}

@override
Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: SfPdfViewer.asset(
          'assets/flutter-succinctly.pdf',
        ),
      ),
    );
  }
}

Implementation

SfPdfViewer.asset(
  String name, {
  Key? key,
  AssetBundle? bundle,
  this.canShowScrollHead = true,
  this.pageSpacing = 4,
  this.controller,
  this.onZoomLevelChanged,
  this.canShowPageLoadingIndicator = true,
  this.canShowScrollStatus = true,
  this.onPageChanged,
  this.onDocumentLoaded,
  this.enableDoubleTapZooming = true,
  this.enableTextSelection = true,
  this.onTextSelectionChanged,
  this.onHyperlinkClicked,
  this.onDocumentLoadFailed,
  this.enableDocumentLinkAnnotation = true,
  this.canShowPaginationDialog = true,
  this.initialScrollOffset = Offset.zero,
  this.initialZoomLevel = 1,
  this.maxZoomLevel = 3,
  this.interactionMode = PdfInteractionMode.selection,
  this.scrollDirection = PdfScrollDirection.vertical,
  this.pageLayoutMode = PdfPageLayoutMode.continuous,
  this.currentSearchTextHighlightColor =
      const Color.fromARGB(80, 249, 125, 0),
  this.otherSearchTextHighlightColor = const Color.fromARGB(50, 255, 255, 1),
  this.password,
  this.canShowPasswordDialog = true,
  this.canShowHyperlinkDialog = true,
  this.enableHyperlinkNavigation = true,
})  : _provider = AssetPdf(name, bundle),
      assert(pageSpacing >= 0),
      super(key: key);