我有一个TabBarView
多页。我希望能够在页面之间“跳转”,而无需平滑地设置它们的动画。给出明确的TabController
:
TabController _controller = TabController(vsync: this, length: myTabs.length);
我已经尝试过这些事情:
直接编辑索引
// Attempt to jump to 5th tab. This results in a smooth animation.
_controller.index = 5;
在即时动画中使用animateTo
// Still animates smoothly
_controller.animateTo(5, duration: Duration(seconds: 0));
编辑索引和偏移量
// Still animates smoothly
// (Also, even if this worked as expected, it would be restricted to 2 tabs)
_controller.offset = 1;
_controller.index = 5;
似乎没有任何效果!有什么建议吗?