简体   繁体   中英

Flutter: how to change label style color when it is selected

i want to when a tab is selected change out color to blue and when it is not selected change the color to grey i already did this

TabBar(
  isScrollable: true,
  labelStyle: TextStyle(
  fontSize: 14.0,
  fontFamily: 'fontfamily',
  color: Colors.blue),
  unselectedLabelStyle:
  TextStyle(
  fontSize: 14.0, fontFamily: 'fontfamily'),
  tabs: myTabs,
  controller: _tabController,
            ),

You can use this:

labelColor: Colors.blue,
unselectedLabelColor: Colors.grey,

You don't have to specify the Text color in the labelStyle

  unselectedLabelColor: Colors.grey, //for unselected label//
  indicatorColor: Colors.grey, //indicates the label color when you click it//
  labelColor: Colors.blue, // shows the label color //

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM