【问题标题】:how to make BottomNavBar persisent while switching to nested screens in flutter?如何在颤振中切换到嵌套屏幕时使 BottomNavBar 持久化?
【发布时间】:2022-12-12 12:23:10
【问题描述】:

  List navScreens = [
      const HomeScreen(),
      const FavoriteScreen(),
      const NotificationScreen(),
      const MyProfilesScreen(),
    ];
Scaffold(
      body: navScreens.elementAt(selectedIndex),
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: selectedIndex,
        iconSize: 34,
        selectedItemColor: ConstColors.green,
        unselectedItemColor: ConstColors.black2,
        elevation: 10,
        onTap: (value) {
          setState(() {
            selectedIndex = value;
          });
        },
        items: const [
          BottomNavigationBarItem(
              icon: Icon(Icons.home_outlined), label: 'home'),
          BottomNavigationBarItem(
              icon: Icon(Icons.bookmark_border_outlined), label: 'favorite'),
          BottomNavigationBarItem(
              icon: Icon(Icons.notifications_none), label: 'notificati`your text`on'),
          BottomNavigationBarItem(``your text``
              icon: Icon(Icons.person_outline), label: 'profile'),
        ],
      ),
    );

当我将屏幕从 BottomNavBar(MainScreen) 切换到内部 (DetailScreen) 时,BottomNavBar 就会消失。如果我直接从嵌套屏幕导航到底部栏屏幕。它也消失了。 Persistent_bottom_bar 是另一种解决方案,但我想通过内置支持修复它。谢谢 !

【问题讨论】:

    标签: flutter flutter-navigation


    【解决方案1】:

    这个package 很适合你的需要。

    【讨论】:

    • 谢谢,我知道这个包,如果 Flutter BottomNavBar Widget 本身有任何内置支持。
    猜你喜欢
    • 1970-01-01
    • 2020-06-04
    • 2021-05-10
    • 2021-09-15
    • 2019-12-10
    • 1970-01-01
    • 2020-10-10
    • 1970-01-01
    • 2019-12-10
    相关资源
    最近更新 更多