Why does my fluttter app keep crashing when loading pdf from the internet?
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)
Please what could be the cause of the consistent crashing? And how do I fix it? Thanks
I actually solved the issue by replacing the package to flutter_pdfview: ^1.2.1