如何根据选择的选项卡更改样式?

时间:2019-02-19 07:02:38

标签: dart flutter tabcontrol

以下是我处理TabBar中的Flutter的代码

TabBar(controller: tabController, indicatorColor: white, tabs: [
        Tab(
          child: Text(
            "Present",
            style: TextStyle(fontFamily: "BarlowBold", color: black),
          ),
        ),
        Tab(
          child: Text(
            "Upcoming",
            style: TextStyle(fontFamily: "BarlowBold", color: black),
          ),
        )
      ]),

我需要根据选择的选项卡来更改文本的fontFamily。我尝试了tabController的属性,但没有帮助

1 个答案:

答案 0 :(得分:1)

可以通过labelStyle:中的unselectedLabelStyle:TabBar来完成相同操作

TabBar(
              indicatorColor: Colors.white,
              labelStyle: TextStyle(fontSize: 22.0,fontFamily: 'Family Name'),  //For Selected tab
              unselectedLabelStyle: TextStyle(fontSize: 10.0,fontFamily: 'Family Name'), //For Un-selected Tabs
              tabs: [