52 lines
1.1 KiB
Dart
52 lines
1.1 KiB
Dart
import 'package:advance_pdf_viewer/advance_pdf_viewer.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class PdfReader extends StatefulWidget {
|
|
const PdfReader({
|
|
Key key,
|
|
this.pdfUrl,
|
|
}) : super(key: key);
|
|
|
|
final String pdfUrl;
|
|
|
|
@override
|
|
_PdfReaderState createState() => _PdfReaderState();
|
|
}
|
|
|
|
class _PdfReaderState extends State<PdfReader> {
|
|
bool isLoading = true;
|
|
PDFDocument document;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
loadDocument();
|
|
}
|
|
|
|
loadDocument() async {
|
|
try {
|
|
document = await PDFDocument.fromURL('https://pdftron.s3.amazonaws.com/downloads/pdfref.pdf');
|
|
setState(() => isLoading = false);
|
|
} catch(e) {
|
|
print(e);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
backgroundColor: Colors.white,
|
|
iconTheme: IconThemeData(
|
|
color: Color(0xFF545454), //change your color here
|
|
),
|
|
),
|
|
body: Center(
|
|
child: isLoading
|
|
? CircularProgressIndicator()
|
|
: PDFViewer(document: document),
|
|
),
|
|
);
|
|
}
|
|
}
|