Reputation: 185
I am building an app in flutter that reads pdf files from the internet. The package I'm using is "advance_pdf_viewer." I have followed everything as instructed in the documentation. But my app always crashes a few seconds after showing the Circular Progress Indicator Widget.
Here's is my code
//@dart=2.9
import 'package:flutter/material.dart';
import 'package:advance_pdf_viewer/advance_pdf_viewer.dart';
class PDFviewerPage extends StatefulWidget {
const PDFviewerPage({Key key}) : super(key: key);
@override
_PDFviewerPageState createState() => _PDFviewerPageState();
}
class _PDFviewerPageState extends State<PDFviewerPage> {
bool _isLoading = true;
PDFDocument _document;
loadDocument() async {
setState(() {
_isLoading = true;
});
final document = await PDFDocument.fromURL(
"https://unec.edu.az/application/uploads/2014/12/pdf-sample.pdf");
setState(() {
_document = document;
_isLoading = false;
});
}
@override
void initState() {
super.initState();
loadDocument();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Example'),
),
body: _isLoading
? const Center(child: CircularProgressIndicator())
: PDFViewer(document: _document),
);
}
}
Also, I have these permissions enabled in my manifest file
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
This is the error message returned in my debug console [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method getPage on channel flutter_plugin_pdf_viewer)
What could be the cause of the consistent crashing? And how do I fix it?
Upvotes: 0
Views: 2905
Reputation: 134
Not sure if it is still actual. Here is what I have tried, according to https://github.com/lohanidamodar/pdf_viewer/issues/117#issuecomment-1259538440 temporary solution could be updating pubspec.yaml
file with the following changes:
Replace the following line:
advance_pdf_viewer: ^2.0.1
with:
advance_pdf_viewer:
git:
url: https://github.com/lohanidamodar/pdf_viewer.git
ref: 4e5d96be29de515f1081c0b6897741b8dca84722
Moreover, there is also another solution using https://pub.dev/packages/advance_pdf_viewer_fork package which doesn't have current issue.
Upvotes: 2
Reputation: 185
I actually solved the issue by replacing the package to flutter_pdfview: ^1.2.1
Upvotes: 1
Reputation: 179
I had the same issue, the only thing that worked for me so far was using the previous version of the package:
(on pubspec.yaml)
advance_pdf_viewer: 2.0.0
Upvotes: 5