1

As I am new to flutter, In Android,

app:tabIndicatorFullWidth="false"

I use this property in tabbar to wrap the indicator size with respect to tab text. May I know how to achieve in flutter?

Balaji
  • 1,773
  • 1
  • 17
  • 30

2 Answers2

8

You can set the isScrollable to true

If isScrollable is true, then each tab is as wide as needed for its label and the entire TabBar is scrollable. Otherwise each tab gets an equal share of the available space.

  bottom: TabBar(
              isScrollable: true, // here

              tabs: [
                Tab(text: 'Car',),
                Tab(text: 'Transit Bus',),
                Tab(text: 'Bike',),
              ],
            ),

References

Tinus Jackson
  • 3,397
  • 2
  • 25
  • 58
  • 1
    This changes the tab's width, and the indicator's width is still the tab's width and not the text's width. OP's answer is correct – Flafy Aug 06 '22 at 12:40
4

I Figured out the answer,

TabBar( controller: _tabController,
                  indicatorColor: Colors.white,
                  indicatorSize: TabBarIndicatorSize.label,
                  tabs: getTabs(),
                )



indicatorSize: TabBarIndicatorSize.label

this property indicatorSize solved my problem.

Balaji
  • 1,773
  • 1
  • 17
  • 30