SfPdfViewer.file constructor Null safety

SfPdfViewer.file(
  1. File file,
  2. {Key? key,
  3. bool canShowScrollHead = true,
  4. double pageSpacing = 4,
  5. PdfViewerController? controller,
  6. PdfZoomLevelChangedCallback? onZoomLevelChanged,
  7. bool canShowScrollStatus = true,
  8. PdfPageChangedCallback? onPageChanged,
  9. bool enableDoubleTapZooming = true,
  10. bool enableTextSelection = true,
  11. PdfTextSelectionChangedCallback? onTextSelectionChanged,
  12. PdfDocumentLoadedCallback? onDocumentLoaded,
  13. PdfDocumentLoadFailedCallback? onDocumentLoadFailed,
  14. bool enableDocumentLinkAnnotation = true,
  15. bool canShowPaginationDialog = true,
  16. Offset initialScrollOffset = Offset.zero,
  17. double initialZoomLevel = 1,
  18. PdfInteractionMode interactionMode = PdfInteractionMode.selection,
  19. PdfScrollDirection scrollDirection = PdfScrollDirection.vertical,
  20. PdfPageLayoutMode pageLayoutMode = PdfPageLayoutMode.continuous,
  21. Color searchTextHighlightColor = const Color(0xFFE56E00)}
)

Creates a widget that displays the PDF document obtained from File.

Note: On Android, this may require the android.permission.READ_EXTERNAL_STORAGE permission.

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

@override
Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: SfPdfViewer.file(
          File('/storage/emulated/0/Download/flutter-succinctly.pdf'),
        ),
      ),
    );
  }
}

Implementation

SfPdfViewer.file(
  File file, {
  Key? key,
  this.canShowScrollHead = true,
  this.pageSpacing = 4,
  this.controller,
  this.onZoomLevelChanged,
  this.canShowScrollStatus = true,
  this.onPageChanged,
  this.enableDoubleTapZooming = true,
  this.enableTextSelection = true,
  this.onTextSelectionChanged,
  this.onDocumentLoaded,
  this.onDocumentLoadFailed,
  this.enableDocumentLinkAnnotation = true,
  this.canShowPaginationDialog = true,
  this.initialScrollOffset = Offset.zero,
  this.initialZoomLevel = 1,
  this.interactionMode = PdfInteractionMode.selection,
  this.scrollDirection = PdfScrollDirection.vertical,
  this.pageLayoutMode = PdfPageLayoutMode.continuous,
  this.searchTextHighlightColor = const Color(0xFFE56E00),
})  : _provider = FilePdf(file),
      assert(pageSpacing >= 0),
      super(key: key);