Home > Net >  How to know if user swipe extent left where no tab to show into tabarView
How to know if user swipe extent left where no tab to show into tabarView

Time:02-16

How can i detect if user swipe left or right extent where no tab to show , i need to make action if is so like call function... i need this for several things .. is it possible ?

     @override
              void initState() {
                super.initState();
                _controllerr =   TabController( length: 2, vsync: this );
                _controllerr!.addListener(test);
              }
        
         test(){
    print('max left extent is scrolled '); 
// here will outputa only when tab changed but not when swipe right or left extent where no page to show 
         
          }
        
        
        
        bottom:TabBar(
          controller:  _controllerr,
               
          tabs: const [
           Tab(text: "page 1",),
          Tab(text: "page 2",),
        
         ],
        ),
        
        
         TabBarView(
            controller: _controllerr,
            children: [
        Twxt('page1')
        Twxt('page2')
        ]
        )

CodePudding user response:

try this out. you know the no of tabs.

  TabBarView(
            controller: _controllerr,
            children: [
                      Twxt('page1')
                      Twxt('page2')
                      ]
            ) 

no of tabs = no of screens

so you know which is the first and last tabs.

so the wrap Twxt('first_page') , Twxt('last_page') with GestureDetector

for first_page :

GestureDetector(
  onPanUpdate: (details) { 
     // for right swipe 
    if (details.delta.dx > 0) {
        //your work
     }
  },
  child: Twxt('first_page'),
)

for last_page :

GestureDetector(
  onPanUpdate: (details) {
   
    // for left swipe 
    if (details.delta.dx < 0) {
          //your work
      }
  },
  child: Twxt('last_page'),
)

hope this will work

  • Related