pdf_flutter 1.1.2

  • Readme
  • Changelog
  • Example
  • Installing
  • new80

pdf_flutter #

pub package

Inspired by Pdf_Viewer_Plugin 😇 Wrapped around AndroidPdfViewer on Android. 🙏🏼

1. Add pdf_flutteron pubspec.yml #

dependencies:
  pdf_flutter: ^version

2. On iOS enable PDF preview like this: #

Add this on ios/Runner/info.plist:

    <key>io.flutter.embedded_views_preview</key>
    <true/>

3. Start Using #

Load PDF from network (caches PDF from network)

    PDF.network(
            'https://raw.githubusercontent.com/FlutterInThai/Dart-for-Flutter-Sheet-cheet/master/Dart-for-Flutter-Cheat-Sheet.pdf',
            height: 500,
            width: 300,
    )
          

Load PDF files

    File fileName;  
    PDF.file(
        fileName,
        height: 200,
        width: 100,
    )
    

Load PDF from assets

    PDF.assets(
        "assets/pdf/demo.pdf",
        height: 200,
        width: 100,
    )

Demo #

demo

1.1.2 Update README

1.1.1 Update README

1.1.0 Supports caching of network PDF

1.0.3 Improved description

1.0.2 Improved changelog

1.0.1 Added support for PDF.file() and PDF.assets()

1.0.0 Added homepage

0.0.1

  • TODO: Describe initial release.

example/lib/main.dart

import 'dart:io';

import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:pdf_flutter/pdf_flutter.dart';

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

class PdfApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        debugShowCheckedModeBanner: false,
        home: Scaffold(
          appBar: AppBar(
            title: Text("pdf_flutter demo"),
          ),
          body: PDFListBody(),
        ));
  }
}

class PDFListBody extends StatefulWidget {
  const PDFListBody({
    Key key,
  }) : super(key: key);

  @override
  _PDFListBodyState createState() => _PDFListBodyState();
}

class _PDFListBodyState extends State<PDFListBody> {
  File localFile;

  @override
  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        Row(
          children: <Widget>[
            Column(
              children: <Widget>[
                Text("PDF.network(url)"),
                PDF.network(
                  'https://google-developer-training.github.io/android-developer-fundamentals-course-concepts/en/android-developer-fundamentals-course-concepts-en.pdf',
                  height: 300,
                  width: 200,
                  placeHolder: Image.asset("assets/images/pdf.png",
                      height: 200, width: 100),
                ),
              ],
            ),
            SizedBox(
              height: 10,
            ),
            Column(
              children: <Widget>[
                Text("PDF.assets(assetname)"),
                PDF.assets(
                  "assets/pdf/demo.pdf",
                  height: 300,
                  width: 200,
                  placeHolder: Image.asset("assets/images/pdf.png",
                      height: 200, width: 100),
                ),
              ],
            ),
          ],
        ),
        SizedBox(
          height: 10,
        ),
        localFile != null
            ? Column(
                children: <Widget>[
                  Text("PDF.file(fileName)"),
                  PDF.file(
                    localFile,
                    height: 300,
                    width: 200,
                    placeHolder: Image.asset("assets/images/pdf.png",
                        height: 200, width: 100),
                  ),
                ],
              )
            : InkWell(
                onTap: () async {
                  File file = await FilePicker.getFile(
                      allowedExtensions: ['pdf'], type: FileType.custom);
                  setState(() {
                    localFile = file;
                  });
                },
                child: Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: Container(
                    height: 300,
                    decoration: BoxDecoration(
                      color: Colors.cyan,
                      borderRadius: BorderRadius.circular(20),
                    ),
                    child: Center(
                      child: Text(
                        "Select PDF from device",
                        textAlign: TextAlign.center,
                        style: TextStyle(fontSize: 45, color: Colors.white),
                      ),
                    ),
                  ),
                ),
              )
      ],
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  pdf_flutter: ^1.1.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:pdf_flutter/pdf_flutter.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
60
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
80
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform android

Because:

  • package:pdf_flutter/pdf_flutter.dart that imports:
  • package:path_provider/path_provider.dart that imports:
  • package:path_provider_linux/path_provider_linux.dart that declares support for platforms: linux

Package does not support Flutter platform ios

Because:

  • package:pdf_flutter/pdf_flutter.dart that imports:
  • package:path_provider/path_provider.dart that imports:
  • package:path_provider_linux/path_provider_linux.dart that declares support for platforms: linux

Package does not support Flutter platform linux

Because:

  • package:pdf_flutter/pdf_flutter.dart that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because:

  • package:pdf_flutter/pdf_flutter.dart that declares support for platforms: android, ios

Package does not support Flutter platform web

Because:

  • package:pdf_flutter/pdf_flutter.dart that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because:

  • package:pdf_flutter/pdf_flutter.dart that declares support for platforms: android, ios

Package not compatible with SDK dart

Because:

  • pdf_flutter that is a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
flutter_cache_manager ^1.4.1 1.4.1
http ^0.12.1 0.12.1
path_provider ^1.6.11 1.6.11
pedantic ^1.9.0 1.9.0 1.9.1
uuid ^2.1.0 2.2.0
Transitive dependencies
charcode 1.1.3
clock 1.0.1
collection 1.14.12 1.14.13
convert 2.1.1
crypto 2.1.5
file 5.2.1
http_parser 3.1.4
intl 0.16.1
meta 1.1.8 1.2.1
path 1.7.0
path_provider_linux 0.0.1+2
path_provider_macos 0.0.4+3
path_provider_platform_interface 1.0.2
platform 2.2.1
plugin_platform_interface 1.0.2
process 3.0.13
rxdart 0.24.1
sky_engine 0.0.99
source_span 1.7.0
sqflite 1.3.1
sqflite_common 1.0.2+1
string_scanner 1.0.5
synchronized 2.2.0+1
term_glyph 1.1.0
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
xdg_directories 0.1.0
Dev dependencies
flutter_test