Ravin Laheri
Ravin Laheri

Reputation: 822

Bottom Navigation Bar for All screen

My aim is to achieve same bottom navigation bar in all screen for that I'm using below methods and package.

I am using below package

persistent_bottom_nav_bar_v2: ^4.2.5

Issue is when I will redirect it from any screen using

pushNewScreen(context, screen: screen, withNavBar: true);

My app bar which is present in below screen is always showing in all screen. But I don't need AppBar in all screens expect below screen.

 List<Widget> pageList = [
    const HomePage(),
    const WearHouseScreen(),
    const OrderScreen(),
    const ProfileScreen(),
  ];

below is my main screen

 @override
  Widget build(BuildContext context) {
    return FancyDrawerWrapper(
      cornerRadius: 30.0,
      controller: fancyDrawerController!,
      backGroundImage: Assets.imagesDrawerBackground,
      drawerItems: DrawerScreen(fancyDrawerController: fancyDrawerController!),
      child: Obx(() {
        return Scaffold(
          appBar: getUserType() != UserTypeEnum.Staff
              ? kmainController.selectedBottomBarIndex.value == 0
                  ? getHomePageAppbar()
                  : kmainController.selectedBottomBarIndex.value == 1
                      ? getWareHouseAppbar()
                      : kmainController.selectedBottomBarIndex.value == 2
                          ? getOrderAppbar()
                          : getProfileAppbar()
              : kmainController.selectedBottomBarIndex.value == 0
                  ? getOrderAppbar()
                  : kmainController.selectedBottomBarIndex.value == 1
                      ? getWareHouseAppbar()
                      : kmainController.selectedBottomBarIndex.value == 2
                          ? getMessageAppBar()
                          : getProfileAppbar(),
          body: PersistentTabView(
            context,
            controller: kmainController.tabController?.value,
            navBarHeight: 60,
            padding: const NavBarPadding.all(5),
            onItemSelected: (value) {
              kmainController.selectedBottomBarIndex.value = value;
            },
            screens: getUserType() == UserTypeEnum.Staff ? staffPageList : pageList,
            items: getUserType() == UserTypeEnum.Staff ? staffNavBar() : adminOwnerNavBar(),
            backgroundColor: AppColors.white,
            resizeToAvoidBottomInset: true,
            hideNavigationBar: false,
            itemAnimationProperties: const ItemAnimationProperties(duration: Duration(milliseconds: 200), curve: Curves.ease),
            screenTransitionAnimation: const ScreenTransitionAnimation(animateTabTransition: true, curve: Curves.ease, duration: Duration(milliseconds: 200)),
            navBarStyle: NavBarStyle.style1,
          ),
        );
      }),
    );
  }

Upvotes: 0

Views: 623

Answers (1)

Dharini
Dharini

Reputation: 857

try this,

Navigator.of(context, rootNavigator: true).push(MaterialPageRoute(
             builder: (_) => ClassName(),
      ),

try this, it was working on my side,

pushNewScreen( context, screen: yourClassName(), withNavBar: false, // OPTIONAL VALUE. True by default. pageTransitionAnimation: PageTransitionAnimation.cupertino, );

Upvotes: 0

Related Questions