[英]How to change the background of unselected Tab Bar in Flutter?
我有一个 Sliver AppBar,它的背景颜色是透明的,滚动它会消失。 这里我想更改未选中标签栏的颜色,虽然文本label颜色可以更改未选中标签但是如何更改标签rest的背景? 我已经尝试过与此相关的先前已回答的查询,但它对我不起作用,或者我可能遗漏了一些东西。 下面是带有屏幕截图的代码。 非常感谢。
NestedScrollView(
controller: _scrollViewController,
headerSliverBuilder: (BuildContext context, bool boxIsScrolled){
return <Widget>[
SliverAppBar(
automaticallyImplyLeading: false,
backgroundColor: Colors.transparent,
floating: true,
pinned: false,
snap: true,
title: TabBar(
isScrollable: true,
controller: _tabController,
unselectedLabelColor: mRed,
labelColor: white,
indicatorColor: Colors.blueGrey,
indicatorSize: TabBarIndicatorSize.label,
indicator: BoxDecoration(
borderRadius: BorderRadius.circular(50),
color: mRed),
tabs: [
Tab(
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50),
border:
Border.all( color:mRed , width: 1),
),
padding: EdgeInsets.all(15),
child: Align(
alignment: Alignment.center,
child: Text("APPS",),
),
),
),
您可以对 colors 使用Ternary operator
并将条件放在索引上,例如
Index == 0 ? Colors.black : Colors.white,
并且 tab1 将引用索引 0 等等
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.