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. UndoHistoryController? undoController,
  8. PdfZoomLevelChangedCallback? onZoomLevelChanged,
  9. bool canShowPageLoadingIndicator = true,
  10. bool canShowScrollStatus = true,
  11. PdfPageChangedCallback? onPageChanged,
  12. PdfDocumentLoadedCallback? onDocumentLoaded,
  13. bool enableDoubleTapZooming = true,
  14. bool enableTextSelection = true,
  15. PdfTextSelectionChangedCallback? onTextSelectionChanged,
  16. PdfHyperlinkClickedCallback? onHyperlinkClicked,
  17. PdfDocumentLoadFailedCallback? onDocumentLoadFailed,
  18. PdfGestureTapCallback? onTap,
  19. PdfFormFieldValueChangedCallback? onFormFieldValueChanged,
  20. PdfFormFieldFocusChangeCallback? onFormFieldFocusChange,
  21. PdfAnnotationCallback? onAnnotationAdded,
  22. PdfAnnotationCallback? onAnnotationSelected,
  23. PdfAnnotationCallback? onAnnotationDeselected,
  24. PdfAnnotationCallback? onAnnotationEdited,
  25. PdfAnnotationCallback? onAnnotationRemoved,
  26. bool enableDocumentLinkAnnotation = true,
  27. bool canShowPaginationDialog = true,
  28. bool canShowSignaturePadDialog = true,
  29. Offset initialScrollOffset = Offset.zero,
  30. double initialZoomLevel = 1,
  31. int initialPageNumber = 1,
  32. double maxZoomLevel = 3,
  33. PdfInteractionMode interactionMode = PdfInteractionMode.selection,
  34. PdfScrollDirection? scrollDirection,
  35. PdfPageLayoutMode pageLayoutMode = PdfPageLayoutMode.continuous,
  36. Color currentSearchTextHighlightColor = const Color.fromARGB(80, 249, 125, 0),
  37. Color otherSearchTextHighlightColor = const Color.fromARGB(50, 255, 255, 1),
  38. String? password,
  39. bool canShowPasswordDialog = true,
  40. bool canShowHyperlinkDialog = true,
  41. 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.undoController,
  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.onTap,
  this.onFormFieldValueChanged,
  this.onFormFieldFocusChange,
  this.onAnnotationAdded,
  this.onAnnotationSelected,
  this.onAnnotationDeselected,
  this.onAnnotationEdited,
  this.onAnnotationRemoved,
  this.enableDocumentLinkAnnotation = true,
  this.canShowPaginationDialog = true,
  this.canShowSignaturePadDialog = true,
  this.initialScrollOffset = Offset.zero,
  this.initialZoomLevel = 1,
  this.initialPageNumber = 1,
  this.maxZoomLevel = 3,
  this.interactionMode = PdfInteractionMode.selection,
  this.scrollDirection,
  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);