How to Disable Swipe TabBar In Flutter ?

· 2 min read
How to Disable Swipe TabBar In Flutter
How to Disable Swipe TabBar In Flutter

TabBar Widget is nothing but a horizontal row of tabs and displays a widget that corresponds to the currently selected tab. To display a horizontal row of tabs, we can use the TabBar Widget. So in this article, we will go through How to Disable Swipe TabBar In Flutter?

How to Disable Swipe TabBar In Flutter?

To disable Swipe TabBar user can by changing how the page view should respond to user input using the physics property. and we have a NeverScrollableScrollPhysics for that purpose so just change physics to that like this :

  • You can disable swiping from TabBarView()
TabBarView(
        physics: NeverScrollableScrollPhysics(),
        controller: tabcontroler,
        children: <Widget>[
          Container(color: Colors.red),
          Container(color: Colors.green),
          Container(color: Colors.blue),
        ],
      ),
  • You can disable scrooling from ListView() , PageView()
ListView.builder(
    // you can set BouncingScrollPhysics() if you show animation when user end of list
          physics: NeverScrollableScrollPhysics(),
          itemCount: categories.length,
          itemBuilder: (BuildContext ctx, int index) {
            return CategoryItem(categories[index]);
          },
)


PageView.builder(
          physics: NeverScrollableScrollPhysics(),
)

Conclusion:

In this article, How to Disable Swipe TabBar In Flutter?

Thanks for being with us !!! Keep Fluttering.

Still, Need a Support for Flutter Development?

FlutterAgency.com is our portal Platform dedicated to Flutter Technology and Flutter Developers. The portal is full of cool resources from Flutter like Flutter Widget GuideFlutter ProjectsCode libs and etc.

FlutterAgency.com is one of the most popular online portal dedicated to Flutter Technology and daily thousands of unique visitors come to this portal to enhance their knowledge on Flutter.

Leave a Reply