How to use PDF Viewer in Flutter example



Here is an example of how to use the `pdf_viewer_plugin` package in Flutter to display a PDF:

First, add the package to your pubspec.yaml file:

dependencies:
  pdf_viewer_plugin: ^1.0.0

Import the package in your Dart file:

import 'package:pdf_viewer_plugin/pdf_viewer_plugin.dart';

Create a PDFViewer widget, passing in the path to your PDF file:

PDFViewer(
  filePath: 'path/to/your/pdf.pdf',
)

You can also pass in additional options, such as the initial page to display, whether to enable pinch-to-zoom and more.

PDFViewer(
  filePath: 'path/to/your/pdf.pdf',
  enableSwipe: true,
  swipeHorizontal: true,
  autoSpacing: true,
  pageFling: true,
  defaultPage: 1,
  fitPolicy: FitPolicy.WIDTH,
)

If not understand please watch this video:

Flutter PDF Package – Flutter PDF viewer from URL

If you want to learn more about flutter read this, How to Scroll Flutter Text and Flutter IOS Button Style.

Leave a Comment