喜欢我的代码:
TabBar(
// isScrollable: true,
unselectedLabelColor: Colors.grey,
labelColor: Colors.black,
// labelColor: Colors.white,
// indicatorSize: TabBarIndicatorSize.tab,
indicator: BoxDecoration(
borderRadius: BorderRadius.circular(50),
color: Colors.white),
tabs: tabs,
controller: _tabController,
)
答案 0 :(得分:0)
TabController _tabController;
@override
void initState() {
super.initState();
_tabController = new TabController(vsync: this, length: 2);
_tabController.addListener(_handleTabSelection);
}
void _handleTabSelection() {
setState(() {
});
}
TabBar(
controller: _tabController,
indicatorColor: Colors.grey,
labelColor: Colors.black,
unselectedLabelColor: Colors.grey,
tabs: [
Tab(
text: 'First',
icon: Icon(Icons.home,
color: _tabController.index == 0
? Colors.black
: Colors.grey)),
Tab(
text: 'Second',
icon: Icon(Icons.person,
color: _tabController.index == 1
? Colors.black
: Colors.grey)),
)