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.
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.
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.
Just by adding isScrollable: true parameter to TabBar() all tabs shrink to one side.
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'), ), ], )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With