jumpTo method Null safety

void jumpTo(
  1. {double xOffset = 0.0,
  2. double yOffset = 0.0}
)

Jumps the scroll position of SfPdfViewer to the specified offset value.

Using this method, the SfPdfViewer can be scrolled or moved to the specified horizontal and vertical offset. If the specified offset value is wrong, then the scroll will not happen and the older position will be retained.

  • xOffset - optional - The value to which the SfPdfViewer scrolls horizontally.
  • yOffset - optional - The value to which the SfPdfViewer scrolls vertically.

Note: If the offset values are not provided, then the the SfPdfViewer will be scrolled or moved to the default position (0, 0).

Returns null.

This example demonstrates how to jump or move the scroll position to the specified offset value.

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.jumpTo(yOffset:1500);
                },
             ),
          ],
       ),
       body: SfPdfViewer.asset(
         'assets/flutter-succinctly.pdf',
         controller: _pdfViewerController,
       ),
     ),
   );
 }
}

Implementation

void jumpTo({double xOffset = 0.0, double yOffset = 0.0}) {
  _horizontalOffset = xOffset;
  _verticalOffset = yOffset;
  notifyPropertyChangedListeners(property: 'jumpTo');
}