syncfusion / flutter-widgets

Syncfusion Flutter widgets libraries include high quality UI widgets and file-format packages to help you create rich, high-quality applications for iOS, Android, and web from a single code base.
1.58k stars 775 forks source link

Pdf Viewer - Can't scroll to the very end when keyboard is opened #2052

Closed ledjoncili closed 3 weeks ago

ledjoncili commented 2 months ago

Bug description

Environment:

Description: When attempting to scroll to the very end of a PDF document using the Syncfusion Flutter PDF Viewer, the viewer does not scroll to the expected position. The issue occurs when trying to set the transformation controller to the maximum offset based on the dimensions of the PDF and the current zoom level.

Steps to reproduce

  1. Run the app

  2. Wait for PDF to be loaded

  3. Click End PAGE button

  4. Click +500 Offset button Result: Pdf is successfully scrolled to the very end

  5. Hot restart the app

  6. Click End PAGE button

  7. Click on PDF Version input and wait for keyboard to be shown

  8. Click +500 Offset button Expected: Pdf is successfully scrolled to the very end Actual: Unable to scroll to the very end

Code sample

import 'package:flutter/material.dart'; import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';

void main() { runApp(const MaterialApp( title: 'Syncfusion PDF Viewer Demo', home: HomePage(), )); }

/// Represents Homepage for Navigation class HomePage extends StatefulWidget { const HomePage({super.key});

@override _HomePage createState() => _HomePage(); }

class _HomePage extends State { final GlobalKey _pdfViewerKey = GlobalKey(); final PdfViewerController _pdfViewerController = PdfViewerController(); double resizeHeight = 0;

@override void initState() { super.initState(); }

@override Widget build(BuildContext context) { debugPrint(MediaQuery.of(context).viewInsets.bottom.toString()); debugPrint(MediaQuery.of(context).size.height.toString()); return Scaffold( resizeToAvoidBottomInset: false, appBar: AppBar( title: const Text('Syncfusion Flutter PDF Viewer'), actions: [ IconButton( icon: const Icon( Icons.bookmark, color: Colors.white, semanticLabel: 'Bookmark', ), onPressed: () { _pdfViewerKey.currentState?.openBookmarkView(); }, ), ], ), body: Column( children: [ Container( alignment: Alignment.bottomCenter, height: MediaQuery.of(context).size.height 0.80 - resizeHeight - (MediaQuery.of(context).viewInsets.bottom 2), // child: Text('Hi there'), child: SfPdfViewer.network( controller: _pdfViewerController, 'https://cdn.syncfusion.com/content/PDFViewer/flutter-succinctly.pdf', key: _pdfViewerKey, ), ), const SizedBox(height: 32.0), Row( children: [ OutlinedButton( onPressed: () { _pdfViewerController.jumpToPage(_pdfViewerController.pageCount); }, child: const Text('End PAGE'), ), OutlinedButton( onPressed: () { _pdfViewerController.jumpTo(yOffset: _pdfViewerController.scrollOffset.dy + 500); }, child: const Text('+500 Offset'), ), OutlinedButton( onPressed: () { setState(() { resizeHeight = 100; }); }, child: const Text('Change Pdf Height'), ), const SizedBox( height: 50, width: 300, child: TextField( decoration: InputDecoration( border: OutlineInputBorder(), labelText: 'PDF VERSION', ), keyboardType: TextInputType.number, ), ), ], ) ], ), ); } }

Screenshots or Video

Screenshots / Video demonstration [Upload media here]

https://github.com/user-attachments/assets/cd256454-62e8-42e0-81bd-253bd184d586

Stack Traces

Stack Traces ```dart [Add the Stack Traces here] ```

On which target platforms have you observed this bug?

iOS

Flutter Doctor output

Doctor output ```console [Add your output here] ```
immankumarsync commented 1 month ago

Hi @ledjoncili, we are able to replicate the reported issue, currently we are validating the issue. The fix for the issue will be available in any of our upcoming weekly release. We will let you know once the issue is resolved.

immankumarsync commented 1 month ago

We have resolved the issue "unable to scroll to the end of the document programmatically when the soft keyboard is raised", and the fix for the same is available in the latest syncfusion_flutter_pdfviewer 27.1.48 package.

Root cause: While using the jumpTo method for scrolling, the height of the soft keyboard is not taken into account during layout.

We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.

Deepak1799 commented 3 weeks ago

@ledjoncili We are closing this as we believe the issue has been resolved. If you need further assistance or have any additional questions, please feel free to reopen the case or reach out to us at any time.