fix: 首页tabController index不及时

This commit is contained in:
guozhigq
2024-01-20 22:31:56 +08:00
parent 5ca841de4e
commit c8e157b2d6

View File

@ -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() {