Skip to content

Commit d0a5793

Browse files
912554: Added notes for not use the setState method in the onPageChanged callback.
1 parent c360ccd commit d0a5793

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Document-Processing/PDF/PDF-Viewer/flutter/page-navigation.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,6 @@ Widget build(BuildContext context) {
234234
}
235235

236236
{% endhighlight %}
237-
{% endtabs %}
237+
{% endtabs %}
238+
239+
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.

0 commit comments

Comments
 (0)