File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -98,7 +98,12 @@ void main() {
9898
9999 test ('open' , () async {
100100 // page number 0 - not available
101- expect (document.getPage (0 ), throwsA (isInstanceOf <PdfPageNotFound >()));
101+ expect (
102+ document.getPage (0 ),
103+ throwsA (
104+ isInstanceOf <PdfNotSupportException >(),
105+ ),
106+ );
102107
103108 page = await document.getPage (3 );
104109 expect (log, < Matcher > [
@@ -117,7 +122,12 @@ void main() {
117122 expect (page.document, document);
118123
119124 // page number 4 more than the document
120- expect (document.getPage (4 ), throwsA (isInstanceOf <PdfPageNotFound >()));
125+ expect (
126+ document.getPage (4 ),
127+ throwsA (
128+ isInstanceOf <PdfNotSupportException >(),
129+ ),
130+ );
121131 });
122132
123133 test ('render' , () async {
Original file line number Diff line number Diff line change 1+ ## 2.1.0
2+
3+ * Added ` onPageChanged ` callback
4+
15## 2.0.0
26
37* Removed default padding
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ class PDFView extends StatefulWidget {
1515 const PDFView ({
1616 @required this .document,
1717 this .controller,
18+ this .onPageChanged,
1819 this .loader = const SizedBox (),
1920 this .scrollDirection = Axis .horizontal,
2021 this .renderer = _render,
@@ -27,6 +28,7 @@ class PDFView extends StatefulWidget {
2728 @required this .document,
2829 @required this .builder,
2930 this .controller,
31+ this .onPageChanged,
3032 this .loader = const SizedBox (),
3133 this .scrollDirection = Axis .horizontal,
3234 this .renderer = _render,
@@ -52,6 +54,9 @@ class PDFView extends StatefulWidget {
5254 /// Page management
5355 final PageController controller;
5456
57+ /// Called whenever the page in the center of the viewport changes
58+ final void Function (int page) onPageChanged;
59+
5560 /// Default PdfRenderer options
5661 static Future <PDFPageImage > _render (PDFPage page) => page.render (
5762 width: page.width * 2 ,
@@ -169,6 +174,7 @@ class _PDFViewState extends State<PDFView> {
169174 itemCount: widget.document.pagesCount,
170175 onPageChanged: (int index) {
171176 _currentIndex = index;
177+ widget.onPageChanged? .call (index+ 1 );
172178 },
173179 controller: widget.controller ?? _pageController,
174180 scrollDirection: widget.scrollDirection,
Original file line number Diff line number Diff line change 11name : native_pdf_view
22description : Flutter plugin to render PDF files on both Android and iOS devices. Provides a Widget to render the pages using a PageView.
3- version : 2.0 .0
3+ version : 2.1 .0
44author : Serge Shkurko <sergeshkurko@outlook.com>
55homepage : https://github.com/rbcprolabs/packages.flutter/tree/master/packages/native_pdf_view
66
You can’t perform that action at this time.
0 commit comments