What is Flutter PDF Viewer? How to Open a PDF in Flutter using flutter_full_pdf_viewer

Flutter PDF viewer is used to read the files ending with the extension ‘.pdf ‘ because pdf is a reliable format for exchanging documents providing a proper security mechanism. These files can contain audio, video and more graphical representation files like GIF, Charts, Vector Graphics.

These can be included in the documents they can be signed electronically too for avoiding unwanted access to these files.

Some times PDF format is preferred to avoid alignment issues in the document like a MS Word where we create a file in windows which can be easily viewed in mac system too. Not only in desktops but these files are much easily accessed in mobile devices of different resolution. And also these are easy to mail or share them because of the less file size.

Opening a PDF with flutter_full_pdf_viewer

In this section, we’ll go over the steps for how to open a PDF in Flutter with flutter_full_pdf_viewer. We’ll assume you already followed the installation instructions to set up the Flutter command-line tools on your machine.

Step 1 — Creating a New Flutter App

We can use the flutter command to create a new Flutter app from the command line (we chose the name opening_a_pdf for our app):

flutter create opening_a_pdf

For the rest of the tutorial, we’ll work in opening_a_pdf:

cd opening_a_pdf

Step 2 — Setting Up Dependencies

We’ll use flutter_full_pdf_viewer, which can be used to display PDFs. We’ll also need path_provider. First, we’ll add them to our pubspec.yaml:

    flutter_full_pdf_viewer: ^1.0.4
    path_provider: ^0.4.1