Repository navigation
Open
Labels
pdf viewerPDF viewer componentwaiting for customer responseCannot make further progress until the customer responds.
Description
Bug description
SfPdfViewer crashes with Null check operator used on a null value at pdfviewer.dart:2460 when a pointer-move is processed while the page is being disposed — _handlePointerMove → _globalToLocal applies ! to a RenderBox (from context.findRenderObject()) that is null during teardown. Same class as the fixed DataGrid #2561 and related to the open _getViewportGlobalRect crash #2565
Steps to reproduce
- Run the sample below on a physical Android device (the race is timing/device-dependent — more reproducible on slower / lower-RAM devices and in release mode).
- Place ~50 single-page PDFs in assets/pages/ (one PDF per page) so each PageView page hosts its own SfPdfViewer.
- Begin a pan/scroll gesture on a page and, while your finger is still moving, swipe horizontally to the next page so a pointer-move is still in flight as the current page's SfPdfViewer is being disposed.
- Repeat rapid swipes back and forth across several pages.
- Crash: Null check operator used on a null value in SfPdfViewerState._globalToLocal (reached via _handlePointerMove) — a RenderBox/BuildContext that is null during disposal is force-dereferenced.
Code sample
Code sample
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';
void main() => runApp(const MaterialApp(home: ReaderDemo()));
/// Paged reader: each PageView page hosts its own SfPdfViewer (one
single-page
/// PDF per page), matching a magazine/e-paper reader. The viewer is created
and
/// disposed as the user swipes. Crashes when a pointer-move gesture is
processed
/// on a page whose SfPdfViewer is being torn down during a swipe.
class ReaderDemo extends StatefulWidget {
const ReaderDemo({super.key});
@override
State<ReaderDemo> createState() => _ReaderDemoState();
}
class _ReaderDemoState extends State<ReaderDemo> {
final PageController _controller = PageController();
// Replace with your own single-page PDFs in assets/pages/ (page_1.pdf …
page_50.pdf).
final List<String> _pages =
List<String>.generate(50, (i) => 'assets/pages/page_${i + 1}.pdf');
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
body: PageView.builder(
controller: _controller,
itemCount: _pages.length,
itemBuilder: (context, index) {
// A fresh SfPdfViewer per page — created/disposed on every swipe.
return SfPdfViewer.asset(
_pages[index],
key: ValueKey('pdf_$index'),
pageLayoutMode: PdfPageLayoutMode.single,
interactionMode: PdfInteractionMode.pan,
canShowScrollHead: false,
canShowScrollStatus: false,
enableDoubleTapZooming: true,
);
},
),
);
}
} ```
</details>
### Screenshots or Video
<details open>
<summary>Screenshots / Video demonstration</summary>
[Upload media here]
</details>
### Stack Traces
<details open><summary>Stack Traces</summary>
```dart
[Add the Stack Traces here]On which target platforms have you observed this bug?
Android
Flutter Doctor output
Doctor output
[Add your output here]Metadata
Metadata
Assignees
Labels
pdf viewerPDF viewer componentwaiting for customer responseCannot make further progress until the customer responds.
Activity
AbinayaSF4962 commentedon Nov 2, 2026
Hi @rumz26 ,
We were unable to reproduce the issue where the null check operator is used on a null value in _globalToLocal during pointer movement while the widget is being disposed on a physical Android device on our end.
Please find the attached sample and screen recording that we used to validate the issue.
Could you please review the attached sample and confirm whether the issue still occurs on your end? If the issue persists, kindly share the affected document, the modified version of the sample project, and the device details. This information will help us investigate and validate the issue further.
sfpdfviewer_gh2569.mp4
sfpdfviewer_gh2569.zip
Regards,
Abinaya E