From 9636cf62cb7f9f452dc5889d754e7b4e7246defb Mon Sep 17 00:00:00 2001 From: ynyx631 Date: Wed, 29 Oct 2025 19:39:18 +0800 Subject: [PATCH] Fix the issue of the comic list loading infinitely. Close #584 --- lib/components/comic.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/components/comic.dart b/lib/components/comic.dart index 6b8a723..8112094 100644 --- a/lib/components/comic.dart +++ b/lib/components/comic.dart @@ -1159,7 +1159,7 @@ class ComicListState extends State { if (res.data.isEmpty) { setState(() { _data[page] = const []; - _maxPage = page; + _maxPage ??= page; }); } else { setState(() { @@ -1282,8 +1282,8 @@ class ComicListState extends State { ], ); } - if (_data[_page] == null) { - _loadPage(_page); + if (_data[1] == null) { + _loadPage(1); return Column( children: [ if (widget.errorLeading != null) widget.errorLeading!, @@ -1304,7 +1304,7 @@ class ComicListState extends State { comics: _data.values.expand((element) => element).toList(), menuBuilder: widget.menuBuilder, onLastItemBuild: () { - if (_error == null && (_maxPage == null || _page < _maxPage!)) { + if (_error == null && (_maxPage == null || _data.length < _maxPage!)) { _loadPage(_data.length + 1); } }, @@ -1334,7 +1334,7 @@ class ComicListState extends State { ], ).paddingHorizontal(16).paddingVertical(8), ) - else if (_maxPage == null || _page < _maxPage!) + else if (_maxPage == null || _data.length < _maxPage!) const SliverListLoadingIndicator(), if (widget.trailingSliver != null) widget.trailingSliver!, ],