Update PDFView in Easyway.

Also, you don’t need to wrap in PDFView inside a StreamBuilder. Just listen to the stream with the listen method, and call that setPage method in the callback.

DownTips Gives you the correct code.

return PDFView(
                  filePath: widget.pdfPath,
                  autoSpacing: true,
                  enableSwipe: true,
                  pageSnap: true,
                  swipeHorizontal: true,
                  defaultPage: currentPage!,
                  onError: (error) {
                    print(error);
                  },
                  onPageError: (page, error) {
                    print('$page: ${error.toString()}');
                  },
                  onRender: (_pages) {
                    setState(() {
                      pages = _pages!;
                      isReady = true;
                      print ('currpage:  $currentPage');
                    });
                  },
                  onViewCreated: (PDFViewController vc)  {
                    setState(() {
                      _pdfController = vc;
                      _controller.complete(vc);
                      vc.setPage(currentPage);
                      print(page);
                      print(snapshot.data?['page']);
                    });

                  },
                  onPageChanged: (int? page, int? total) {
                    setState(() {
                      currentPage = page!;
                    });

                  });`

By Admin