PersistentBottomNavBarV2 icon indicating copy to clipboard operation
PersistentBottomNavBarV2 copied to clipboard

App bar is not Hiding when using with pushNewScreen.

Open rlaheri99 opened this issue 3 years ago • 1 comments

Hey, I am using below version 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.

  @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,
          ),
        );
      }),
    );
  }

flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.5, on Mac OS X 10.15.7 19H2 darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[!] Xcode - develop for iOS and macOS (Xcode 12.4)
    ✗ Flutter requires Xcode 13 or higher.
      Download the latest version or update via the Mac App Store.
    ! CocoaPods 1.5.2 out of date (1.11.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] VS Code (version 1.70.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

rlaheri99 avatar Sep 16 '22 06:09 rlaheri99

That is caused by the Scaffold that is wrapped around the PersistentTabView. So all screens pushed with withNavBar: true will be inside the PersistentTabView (-> in the body of your scaffold). To solve that, move your scaffold into each of your screens and remove it here. This also makes your code for choosing the correct appbar easier

jb3rndt avatar Sep 17 '22 13:09 jb3rndt