簡體   English   中英

如何在顫動中更改“TabBar”中未選擇的選項卡背景顏色?

[英]How to change unselected tabs background color in `TabBar` in flutter?

以下是我的代碼:

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,
                )

我正在嘗試更改未選擇選項卡的背景顏色,就像在我的模擬中一樣標簽

 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)),
  )

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM