Disable swipe gesture when using BottomNavigationBar
Asked Answered
S

2

4

How do we disable swipe on BottomNavigationBar attached to a scaffold?

I could not find a way in the official docs to do so.

Smolt answered 4/8, 2018 at 19:14 Comment(1)
It would be easier to answer your question if you included the code you're working with, or even better, a minimal, complete, and verifiable code excerpt to reproduce your problem. See stackoverflow.com/help/mcveLemire
S
12

Got it:

Just use

physics: const NeverScrollableScrollPhysics()

on your scrollable widget!

Smolt answered 4/8, 2018 at 19:22 Comment(0)
A
0

I use Auto Route package so for me this means adding
physics: const NeverScrollableScrollPhysics() to AutoTabsRouter.pageView

  return AutoTabsRouter.pageView(
      physics: const NeverScrollableScrollPhysics(), // <-----
      routes: const [
        Route1(),
        Route2(),
        Route3(),
      ],
      builder: (context, child, pageController) {
        return Scaffold(
          body: child,
          bottomNavigationBar: AppBottomNavBar(
              currentIndex: context.tabsRouter.activeIndex,
              setActiveIndex: context.tabsRouter.setActiveIndex),
        );
      },
    );
Ackerman answered 1/9 at 18:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.