Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize tabbar width in flutter?

Hi can we customize tabbar width in flutter ? my tabbar width is fixed in here so when i have long text in my tabbar it will not shown completetly, i want to make my tabbar width is flexible base on the content so when my text is just short text the tabbar width will be small and when the text is long text the tabbar width be bigger than the short text tab. I've been try search it on internet but i can't found any answer to fix my issues.

enter image description here

like image 361
Theodorus Agum Gumilang Avatar asked Jul 09 '18 06:07

Theodorus Agum Gumilang


People also ask

How do you set the width of a TabBar Flutter?

Users can give TabBar Widget a property of isScrollable: true if you don't want the tabs to expand to fill the screen horizontally the way they do by default. Users can use indicatorSize: TabBarIndicatorSize. label on the TabBar to make the indicator the same size as the label.

How do you reduce the TabBar indicator size in Flutter?

You can use a Container wrapped in a PreferredSize to size the TabBar . (The PreferredSize is only necessary if you want it to live in the bottom slot of an AppBar .) This has the effect of making the indicators appear narrower because the TabBar doesn't fill the screen.

How do I reduce the gap between tabs in Flutter?

Just by adding isScrollable: true parameter to TabBar() all tabs shrink to one side.


1 Answers

TabBar(isScrollable: true) 

Makes a scrollable tab bar. it's useful when your tab text content or number of your tabs doesn't fit into display size.

or maybe you can do something like this:

child: new TabBar(             tabs: [               new Container(                 width: 30.0,                 child: new Tab(text: 'hello'),               ),               new Container(                   child: new Tab(text: 'world'),               ),             ],           ) 
like image 180
behzad besharati Avatar answered Sep 18 '22 15:09

behzad besharati