From c8e157b2d609dfc3013157d6ff2c1e199b34e933 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 20 Jan 2024 22:31:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=A6=96=E9=A1=B5tabController=20index?= =?UTF-8?q?=E4=B8=8D=E5=8F=8A=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/home/controller.dart | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/pages/home/controller.dart b/lib/pages/home/controller.dart index 3a742519..614d103a 100644 --- a/lib/pages/home/controller.dart +++ b/lib/pages/home/controller.dart @@ -41,6 +41,21 @@ class HomeController extends GetxController with GetTickerProviderStateMixin { ); hideSearchBar = setting.get(SettingBoxKey.hideSearchBar, defaultValue: true); + + // 监听 tabController 切换 + tabController.animation!.addListener(() { + if (tabController.indexIsChanging) { + if (initialIndex.value != tabController.index) { + initialIndex.value = tabController.index; + } + } else { + final int temp = tabController.animation!.value.round(); + if (initialIndex.value != temp) { + initialIndex.value = temp; + tabController.index = initialIndex.value; + } + } + }); } void onRefresh() {