How To Disable Swiping Tabbar Using Flutter Android App

admin_img Posted By Bajarangi soft , Posted On 29-10-2020

you can achieve that by changing how the page view should respond to user input using the physics property. and we have a if i understand you correctly you are trying to disable the indicator because i don't understand what do you mean by "swiping" in TabBar – Raouf Rahiche Jul 25 '18 at 14:44 By swipe: i mean you you can move from tab to another by swiping left or right – André Abboud Jul 25 '18 at 15:11

How To Disable Swiping Tabbar Using Flutter Android App

Disable Swiping Tabbar 
Complete Code For Disable Swiping Tabbar In Flutter
Main.dart

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'APP',
      home: DisableSwipingTabbar(),
    );
  }
}
class DisableSwipingTabbar extends StatefulWidget {
  @override
  DisableSwipingTabbarState createState() {
    return new DisableSwipingTabbarState();
  }
}

class DisableSwipingTabbarState extends State<DisableSwipingTabbar>
    with SingleTickerProviderStateMixin {
  TabController _tabController;

  @override
  void initState() {
    super.initState();
    _tabController = TabController(
      length: 2,
      vsync: this,
      initialIndex: 0,
    )..addListener(() {
      setState(() {
        _tabController.index = 0;
      });
    });
  }

  @override
  void dispose() {
    _tabController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.green,
        title: Text("Disable onTap Tabbar"),
        bottom: TabBar(
          controller: _tabController,
          tabs: <Widget>[
            Tab(
              text: "First Tab",
            ),
            Tab(
              text: "Second Tab",
            ),
          ],
        ),
      ),
      body: TabBarView(
        controller: _tabController,
        physics: NeverScrollableScrollPhysics(),
        children: <Widget>[
          Center(
            child: Text("First Tab"),
          ),
          Center(
            child: Text("Second Tab"),
          ),
        ],
      ),
    );
  }
}

Related Post