繁体   English   中英

如何更改 flutter 中的指示器颜色

[英]how to change indicator color in flutter

如图所示,我的第一个标签是绿色的

选项卡标题是彩色的,下划线不是

选项卡标题是彩色的,下划线不是

是否可以用相同颜色的green为标题下的线条着色?

child: TabBar(
                  onTap: (index) {
                    setState(() {
                      selectedIndex = index;
                    });
                  },
                  isScrollable: false,
                  padding: const EdgeInsets.symmetric(horizontal: 10),
                  controller: _tabController,
                  labelColor: getIndicatorAndLabelColor(selectedIndex),
                  unselectedLabelColor: Colors.black,
                  indicatorWeight: 4,
                  indicatorColor: getIndicatorAndLabelColor(selectedIndex),
                 indicatorPadding:
                      const EdgeInsets.only(left: 15, right: 15, bottom: 10),
                  indicator: const ShapeDecoration(
                      shape: UnderlineInputBorder(
                          borderSide: BorderSide(
                              color: myAccentColor,
                              width: 3,
                              style: BorderStyle.solid))),
                  tabs: const [
                    Tab(
                      text: 'APPROVED',
                    ),
                    Tab(
                      text: 'DENIED',
                    ),
                    Tab(
                      text: 'PENDING',
                    ),
                  ],
                ),

您可以使用indicatorColor将其设置为绿色。

TabBar(
  indicatorColor: Colors.green, //this one , you can remove `getIndicatorAndLabelColor`
  indicatorWeight: 4,
  indicatorPadding:
      const EdgeInsets.only(left: 15, right: 15, bottom: 10),
  tabs: <Widget>[

谢谢@Yeasin Sheikh,终于我找到了解决方案

        indicator: ShapeDecoration(
              shape: UnderlineInputBorder(
                borderSide: BorderSide(
                    color: Colors.green,
                    width: 3,
                    style: BorderStyle.solid),
              ),
            ),

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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