【问题标题】:Flutter bottom navigation bar make item with no route颤动底部导航栏使项目没有路线
【发布时间】:2021-10-24 01:52:58
【问题描述】:

有没有一种方法可以使底部导航栏上的项目无法点击且无法路由到任何地方?我的问题可能没有意义。

谢谢。

【问题讨论】:

  • 我的回答对你没有帮助吗?

标签: flutter navbar bottom


【解决方案1】:

假设您想在导航栏中停用deactiveIndex。使用这个:

bottomNavigationBar: BottomNavigationBar(
        items: const <BottomNavigationBarItem>[
          BottomNavigationBarItem(
            icon: Icon(Icons.home),
            label: 'Home',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.business),
            label: 'Business',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.school),
            label: 'School',
          ),
        ],
        currentIndex: _selectedIndex,
        selectedItemColor: Colors.amber[800],
        onTap:(index){
           if(index == deactiveIndex){ return;}
           setState((){_selectedIndex=index});
        },
      ),

要获得更多 UI 表示,您可以为活动索引设置 activeIcon 或更改反应索引的 color 和 style。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-07
    • 1970-01-01
    • 1970-01-01
    • 2022-11-29
    • 1970-01-01
    相关资源
    最近更新 更多