Manage pagination states and UI feedback
mainEffective pagination requires managing several state variables to prevent duplicate requests and provide user feedback.
Required State Variables:
_currentPage: The current page number (starting from 1).hasMoreChats: A boolean indicating if more data is available to load.isLoadingChats: A boolean indicating if a network request is currently active._isLoadingMore: A local flag used to prevent duplicate triggers during rapid scrolling.
UI Feedback States:
- Loading: Display a spinner animation with the text "正在下载数据..." (Downloading data...).
- No More Data: Display the message "—— 没有更多了 ——" (No more data) when
hasMoreChatsis false. - Ready to Scroll: Ensure sufficient whitespace/footer height (recommended ~50px) to allow the
ScrollControllerto detect the trigger distance.