pdf_viewer_plugin 0.0.5

pdf_viewer_plugin #

A new Flutter plugin to view pdfs

Getting Started #

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

For help on editing plugin code, view the documentation.

[0.0.1] - TODO: Add release date.

  • TODO: Describe initial release.


import 'dart:async';
import 'dart:io';
import 'dart:typed_data';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:pdf_viewer_plugin/pdf_viewer_plugin.dart';
import 'package:path_provider/path_provider.dart';
import 'package:http/http.dart' as http;

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

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

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  initState() {

  Future<String> get _localPath async {
    final directory = await getApplicationDocumentsDirectory();

    return directory.path;

  Future<File> get _localFile async {
    final path = await _localPath;
    return new File('$path/teste.pdf');

  Future<File> writeCounter(Uint8List stream) async {
  final file = await _localFile;
  // Write the file
  return file.writeAsBytes(stream);

  Future<bool> existsFile() async {
  final file = await _localFile;
  return file.exists();
  Future<Uint8List> fetchPost() async {
  final response =
      await http.get('https://expoforest.com.br/wp-content/uploads/2017/05/exemplo.pdf');
  final responseJson = response.bodyBytes;

  return responseJson;

  initPlatformState() async {
    String platformVersion;
    try {

      writeCounter(await fetchPost());
      var x = await existsFile();
      PdfViewerPlugin.getPdfViewer((await _localFile).path, 80.0, 320.0, 600.0);

    } on PlatformException {
      platformVersion = 'Failed to get platform version.';

    if (!mounted)

    setState(() {
      _platformVersion = platformVersion;

  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Plugin example app'),
        body: new Center(
          child: new Column(children: <Widget>[
              new Text("Hello"),
              new RaisedButton(
                child: new Text("Clique aqui"),
                onPressed: initPlatformState
              new RaisedButton(
                  child: new Text("close"),
                  onPressed: () { PdfViewerPlugin.close(); }

Use this package as a library

1. Depend on it

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

  pdf_viewer_plugin: ^0.0.5

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_viewer_plugin/pdf_viewer_plugin.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 Aug 19, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.4


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/pdf_viewer_plugin.dart.

Run flutter format to format lib/pdf_viewer_plugin.dart.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8