jumpToPage method Null safety

void jumpToPage(
  1. int pageNumber
)

Navigates to the specified page number in a PDF document.

Using this method, the SfPdfViewer navigates to the specified page number in a PDF document. If the specified page number is wrong, then the navigation will not happen and the older page will be retained.

  • pageNumber - required - The destination page number to which the SfPdfViewer should navigate to.

Returns null.

This example demonstrates how to navigate to the specified page number.

class MyAppState extends State<MyApp>{
 late PdfViewerController _pdfViewerController;

 @override
 void initState(){
   _pdfViewerController = PdfViewerController();
   super.initState();
 }

 @override
 Widget build(BuildContext context) {
   return MaterialApp(
     home: Scaffold(
       appBar: AppBar(
          title: Text('Syncfusion Flutter PdfViewer'),
          actions: <Widget>[
             IconButton(
                icon: Icon(
                   Icons.arrow_drop_down_circle,
                   color: Colors.white,
                ),
                onPressed: () {
                   _pdfViewerController.jumpToPage(5);
                },
             ),
          ],
       ),
       body: SfPdfViewer.asset(
         'assets/flutter-succinctly.pdf',
         controller: _pdfViewerController,
       ),
     ),
   );
 }
}

Implementation

void jumpToPage(int pageNumber) {
  _pageNavigator = Pagination(Navigation.jumpToPage, index: pageNumber);
  notifyPropertyChangedListeners(property: 'pageNavigate');
}