首页 > 其他分享 >flutter tabbar切换监听及索引获取

flutter tabbar切换监听及索引获取

时间:2022-12-10 16:36:02浏览次数:55  
标签:tabController TabController 监听 索引 indexIsChanging tabbar flutter

参考:https://www.jianshu.com/p/f1347e658fa6

 

定义

late TabController _controller;

 

在 void initState()中监听

 

  tabController = TabController(length: tabs.length, vsync: this)
      ..addListener(() {
         // or (tabController.indexIsChanging) 
        if (!tabController.indexIsChanging) {  // 
          print("监听切换tab ${tabController.index} "); // 打印索引
        }
      });

 

标签:tabController,TabController,监听,索引,indexIsChanging,tabbar,flutter
From: https://www.cnblogs.com/lude1994/p/16971785.html

相关文章