简体   繁体   中英

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?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM