我花了几个小时才发现如何在滚动listView直到(x)项目/标题时更改选项卡的色调,
我开始学习here的扑动
用户界面看起来像:
我想知道如何处理ListView
和tabBar
以防万一我滚动直到Flutter很棒51 tabBar
指标应该改变到右边,同样的事情应该与tabBar
一起工作,当我按下tabBar
指数51时ListView
应该滚动到Flutter真棒51,
任何人都可以指导我如何实现这一目标?
你需要使用
_tabController.animateTo((index))
结合使用
final _position = ... // half or top depending on tab selection itemsize and count
_scrollController.animateTo(_position,
curve: Curves.linear, duration: Duration(milliseconds: 500));
如果列表项具有相同的高度,则可以依靠滚动的偏移和位置来检测它何时达到一半。
Here is an implementation of the ScrollController that will aid you.