From 474d9aa6f1c9dc01c302bc90494221415683e27e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A7=92=E7=A0=82=E7=B3=96?= <90336521+lings03@users.noreply.github.com> Date: Sun, 16 Mar 2025 07:58:28 +0800 Subject: [PATCH] Default to displaying the last read chapter group. (#264) --- lib/pages/comic_details_page/chapters.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/pages/comic_details_page/chapters.dart b/lib/pages/comic_details_page/chapters.dart index 0a9586f..10ece3d 100644 --- a/lib/pages/comic_details_page/chapters.dart +++ b/lib/pages/comic_details_page/chapters.dart @@ -186,12 +186,17 @@ class _GroupedComicChaptersState extends State<_GroupedComicChapters> late TabController tabController; - int index = 0; + late int index; @override void initState() { super.initState(); history = widget.history; + if (history?.group != null) { + index = history!.group! - 1; + } else { + index = 0; + } } @override @@ -199,6 +204,7 @@ class _GroupedComicChaptersState extends State<_GroupedComicChapters> state = context.findAncestorStateOfType<_ComicPageState>()!; chapters = state.comic.chapters!; tabController = TabController( + initialIndex: index, length: chapters.ids.length, vsync: this, );