How can I customize the TabBar indicator width and height?

后端 未结 5 664
傲寒
傲寒 2020-12-30 13:08

I\'m using a TabBar widget and I\'d like to customize the height and width of the indicator. I can\'t see any other property besides color I can modify.

5条回答
  •  -上瘾入骨i
    2020-12-30 13:40

    You can use indicatorSize: TabBarIndicatorSize.label on the TabBar to make the indicator the same size as the label.

    Or you could set the indicator directly, this is a Decoration which you can customize:

    AppBar(
        bottom: TabBar(
            indicator: UnderlineTabIndicator(
              borderSide: BorderSide(width: 5.0),
              insets: EdgeInsets.symmetric(horizontal:16.0)
            ),
            tabs: [
              Tab(text: 'tab 1'),
              Tab(text: 'tab 2'),
              Tab(text: 'tab 3'),
            ],
         ),
    );
    

    For more customisation options check this post

提交回复
热议问题