Balaji
Balaji

Reputation: 2077

Flutter - Wrap tab indicator width with respect to tab text

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?

Upvotes: 1

Views: 6160

Answers (2)

Balaji
Balaji

Reputation: 2077

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.

Upvotes: 5

Tinus Jackson
Tinus Jackson

Reputation: 3653

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

Upvotes: 8

Related Questions