[英]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.