flutter_pdf_renderer 1.3.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 88

flutter_pdf_renderer #

Flutter Plugin to render a PDF file. Supports both Android and iOS.

Getting Started #

In your flutter project add the dependency:

  flutter_pdf_renderer: any

For help getting started with Flutter, view the online documentation.

Usage example #

Import flutter_pdf_renderer.dart

import 'package:flutter_pdf_renderer/flutter_pdf_renderer.dart';

Rendering PDF files on Android devices #

Use the provided widget PdfRenderer in order to render a PDF file. This plugin uses the Android native PdfRenderer to render the pages of PDF files and provides a widget called PdfRenderer to display the PDF page you like.

1.3.2 #

  • Added missing SWIFT_VERSION 4.2 to pod spec file for ios devices. (Thanks to @qinwenshi)

1.3.1 #

  • Added iOS support for rendering a pdf file from an absolute path.

1.3.0 #

  • Added the ability to provide an absolute path to where the pdf file to render is stored. This allows now to render a pdf document that was downloaded at runtime (Android only!).

1.2.0 #

  • Added required parameter for the width to prevent a missing size flutter error when using the PageView widget.

1.1.1 #

  • Fixed example

1.1.0 #

  • Rendering pages of PDF file using PageView.
  • Fixed path to the PdfRenderer Widget.
  • Added full native support for iOS.

1.0.3 #

  • Fixed already closed error

1.0.2 #

  • Fixed a typo in the description.

1.0.1 #

  • Added doc comments and updated the description.

1.0.0 #

  • Initial release with support for android only.


flutter_pdf_renderer_example #

Demonstrates how you can use the flutter_pdf_renderer plugin.

This example project let you download an arbitrary pdf file from the internet. After downloading the pdf file will be instantly rendered. When rendering a pdf document that has multiple pages, simply swipe right or left to navigate through the pdf document.

import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_pdf_renderer/flutter_pdf_renderer.dart';
import 'package:path_provider/path_provider.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  _MyAppState createState() => _MyAppState();

class _MyAppState extends State<MyApp> {
  Future<String> downloadedFilePath;
  TextEditingController controller = TextEditingController();

  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('PdfRenderer example app'),
        body: Column(children: <Widget>[
            controller: controller,
            decoration: InputDecoration(
              hintText: 'Enter URL here...',
            onPressed: download,
            child: Text('Render PDF'),
            future: downloadedFilePath,
            builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
              Text text = Text('');
              if (snapshot.connectionState == ConnectionState.done) {
                if (snapshot.hasError) {
                  text = Text('Error: ${snapshot.error}');
                } else if (snapshot.hasData) {
                  text = Text('Data: ${snapshot.data}');
                  return PdfRenderer(pdfFile: snapshot.data, width: 500.0);
                } else {
                  text = Text('Unavailable');
              } else if (snapshot.connectionState == ConnectionState.waiting) {
                text = Text('Downloading PDF File...');
              } else {
                text = Text('Please load a PDF file.');
              return Container(
                child: text,

  void download() {
    setState(() {
      downloadedFilePath = downloadPdfFile(controller.text);

  Future<String> downloadPdfFile(String url) async {
    final filename = url.substring(url.lastIndexOf("/") + 1);
    String dir = (await getTemporaryDirectory()).path;
    File file = new File('$dir/$filename');
    bool exist = false;
    try {
      await file.length().then((len) {
        exist = true;
    } catch (e) {
    if (!exist) {
      var request = await HttpClient().getUrl(Uri.parse(url));
      var response = await request.close();
      var bytes = await consolidateHttpClientResponseBytes(response);
      await file.writeAsBytes(bytes);
    return file.path;

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  flutter_pdf_renderer: ^1.3.2

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_pdf_renderer/flutter_pdf_renderer.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 25, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health suggestions

Format lib/flutter_pdf_renderer.dart.

Run flutter format to format lib/flutter_pdf_renderer.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8