flutter tabBar 选项卡自定义指示器

使用flutter TabBar 做自定义选项卡。

       1.根据index  使用三目运算,缺点点击以后没有滑动效果。

            tabs:TabMoudels.map((i) => Container(
                      padding: EdgeInsets.all(0),
                      height: 76.h,
                      child: Tab(
                        child: Row(
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            Container(
                              width: MediaQuery.of(context).size.width/3,
                              height: 76.h,
                              child: Column(
                                mainAxisAlignment: MainAxisAlignment.center,
                                crossAxisAlignment: CrossAxisAlignment.center,
                                children: [
                                  Text(i),
                                  SizedBox(
                                    height: 5,
                                  ),
                                  TabMoudels.indexOf(i)==_currentIndex?Container(
                                    width: 15,
                                    height: 4,
                                    decoration: BoxDecoration(
                                      //这里面写颜色
                                      color: Colors.blue,
                                      borderRadius: BorderRadius.circular(1)
                                    ),
                                  ):Container()
                                ],
                              ),
                            )
                          ],
                        ),
                      ),
                )).toList()),

 

  2. 使用官方的指示器  

indicator: UnderlineTabIndicator(),可以找到UnderlineTabIndicator源码,自己新建一个文件,

修改 成为  StrokeCap.round; 这时候的指示器 就有圆角了。

 

滑动也有效果,美滋滋

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值