在Flutter中,如何在没有动画的情况下立即在TabView页面之间导航?

时间:2020-11-04 10:02:07

标签: flutter dart animation tabs

我有一个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;

似乎没有任何效果!有什么建议吗?

0 个答案:

没有答案
相关问题