From d32d4f4b66fc2f45e88a2c7e724583c6e91e656b Mon Sep 17 00:00:00 2001 From: Lingeshwaran S Date: Thu, 16 Jul 2026 15:36:50 +0530 Subject: [PATCH] 912554: Added notes for not use the setState method in the onPageChanged callback. --- Document-Processing/PDF/PDF-Viewer/flutter/page-navigation.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Document-Processing/PDF/PDF-Viewer/flutter/page-navigation.md b/Document-Processing/PDF/PDF-Viewer/flutter/page-navigation.md index 5a0759eda7..f62b1e3801 100644 --- a/Document-Processing/PDF/PDF-Viewer/flutter/page-navigation.md +++ b/Document-Processing/PDF/PDF-Viewer/flutter/page-navigation.md @@ -234,4 +234,6 @@ Widget build(BuildContext context) { } {% endhighlight %} -{% endtabs %} \ No newline at end of file +{% endtabs %} + +N> Avoid calling `setState()` inside the `onPageChanged` or `onDocumentLoaded` callbacks. Doing so rebuilds the entire widget tree — including the `SfPdfViewer` — which can decrease performance when viewing large PDF documents. Instead, use an `addListener()` to the `PdfViewerController` to monitor page changes and update only the specific UI elements that need to change (for example, the page number indicator). This keeps viewer rebuilds to a minimum and delivers smoother scrolling and better stability with large PDF files. \ No newline at end of file