I am using DefaultTabController for tabbar view but i have many tabs to filter data but its not scrolling and i cant see text of tab
how to make it scrollable so that all tabs can be viewed properly
Widget build(BuildContext context) {
final list = ['Furniture', 'Clothe', 'Mobiles', 'Laptop','Accessories','Stationary',];
return DefaultTabController(
length: list.length,
child: Scaffold(
appBar: AppBar(
bottom: TabBar(
tabs: list
.map((e) => Tab(
text: e,
),
)
.toList(),
),
),
body: TabBarView(
children: list.map((e) => CustomScreen(string: e)).toList(),
),
));
}
2
Answers
You can add isScrollable to true in Tabbar:
To make the TabBar scrollable when there are many tabs, you can wrap it with a SingleChildScrollView and set the scrollDirection property to Axis.horizontal. Here’s how you can modify your code to achieve this: