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

问题描述 投票:0回答:1

以下是我在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的属性,但他们没有帮助

dart flutter tabcontrol
1个回答
2
投票

同样可以使用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: [
© www.soinside.com 2019 - 2024. All rights reserved.