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