From 689700f52a2212643388dba42be0a00575995573 Mon Sep 17 00:00:00 2001 From: nyne Date: Mon, 18 Nov 2024 17:42:20 +0800 Subject: [PATCH] improve tab bar --- lib/components/appbar.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/components/appbar.dart b/lib/components/appbar.dart index 6573dea..80c67f7 100644 --- a/lib/components/appbar.dart +++ b/lib/components/appbar.dart @@ -369,10 +369,14 @@ class _FilledTabBarState extends State { final double tabWidth = tabRight - tabLeft; final double tabCenter = tabLeft + tabWidth / 2; final double tabBarWidth = tabBarBox.size.width; - final double scrollOffset = tabCenter - tabBarWidth / 2; + double scrollOffset = tabCenter - tabBarWidth / 2; if (scrollOffset == scrollController.offset) { return; } + scrollOffset = scrollOffset.clamp( + 0.0, + scrollController.position.maxScrollExtent, + ); scrollController.animateTo( scrollOffset, duration: const Duration(milliseconds: 200),