From 6a7aa46df5074d531c8c179f07a65bfd638df40c Mon Sep 17 00:00:00 2001 From: Natty Date: Mon, 22 Jun 2026 17:05:25 +0300 Subject: [PATCH] fix: preserve pdf scroll position on dark mode toggle --- lib/screens/reading/widgets/pdf_view.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/screens/reading/widgets/pdf_view.dart b/lib/screens/reading/widgets/pdf_view.dart index a3d36ef..0b0d8fd 100644 --- a/lib/screens/reading/widgets/pdf_view.dart +++ b/lib/screens/reading/widgets/pdf_view.dart @@ -213,7 +213,10 @@ class _ReadingPdfViewState extends State { duration: const Duration(milliseconds: 150), curve: Curves.easeIn, child: ColorFiltered( - key: ValueKey(widget.settings.theme), + // No key here: keying by theme would tear down and rebuild the + // PdfViewer subtree on every theme change, resetting scroll to the + // top. ColorFiltered updates its filter in place, so the viewer + // (and its scroll position) is preserved across theme switches. colorFilter: colorFilter, child: pdfViewer, ),