Flutter 如何使用活动菜单项上的顶行创建颤振底部导航?

Flutter 如何使用活动菜单项上的顶行创建颤振底部导航?,flutter,dart,Flutter,Dart,我有下面的颤振底部导航栏 我想为像这样的活动项目添加顶行或边界 这是可能的,我的代码是直截了当的 @override Widget build(BuildContext context) { return Scaffold( body: _tabs[_tabIndex], bottomNavigationBar: BottomNavigationBar( backgroundColor: Colors.white, selec

我有下面的颤振底部导航栏

我想为像这样的活动项目添加顶行或边界

这是可能的,我的代码是直截了当的

@override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _tabs[_tabIndex],
      bottomNavigationBar: BottomNavigationBar(
        backgroundColor: Colors.white,
        selectedLabelStyle: TextStyle(fontSize: 14),
        selectedItemColor: Theme.of(context).accentColor,
        unselectedLabelStyle: TextStyle(fontSize: 14.0),
        unselectedItemColor: Color(0xff546481),
        type: BottomNavigationBarType.fixed,
        showSelectedLabels: true,
        showUnselectedLabels: true,
        currentIndex: _tabIndex,
        onTap: (int index) {
          setState(() {
            _tabIndex = index;
          });
        },
        items: const <BottomNavigationBarItem>[
          BottomNavigationBarItem(
            icon: Icon(Icons.home_outlined),
            label: 'HOME',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.history_outlined),
            label: 'HISTORY',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.person_outline),
            label: 'PROFILE',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.settings_outlined),
            label: 'SETTINGS',
          ),
        ],
      ),
    );
  }
}
@覆盖
小部件构建(构建上下文){
返回脚手架(
正文:_tabs[_tabIndex],
底部导航栏:底部导航栏(
背景颜色:Colors.white,
selectedLabelStyle:TextStyle(字体大小:14),
selectedItemColor:Theme.of(context).accentColor,
未选择的标签样式:文本样式(fontSize:14.0),
unselectedItemColor:Color(0xff546481),
类型:BottomNavigationBarType.fixed,
showSelectedLabels:true,
showUnselectedLabels:true,
currentIndex:\u tabIndex,
onTap:(int索引){
设置状态(){
_tabIndex=索引;
});
},
项目:常数[
底部导航气压计(
图标:图标(图标。主页),
标签:“家”,
),
底部导航气压计(
图标:图标(图标、历史),
标签:“历史”,
),
底部导航气压计(
图标:图标(图标、人物轮廓),
标签:“配置文件”,
),
底部导航气压计(
图标:图标(图标、设置),
标签:“设置”,
),
],
),
);
}
}

有一些软件包可以达到这种效果:

class\u HomePageState扩展状态{
最终清单项目=[
底部指示灯激活BarItem(图标:Icons.home),
底部指示灯nAvigationBarItem(图标:Icons.search),
底部指示灯nAvigationBarItem(图标:Icons.settings),
];
@凌驾
小部件构建(构建上下文){
返回脚手架(
appBar:appBar(
标题:文本(“指示器底部栏”),
背景颜色:Colors.teal,
),
正文:中(
子:列(
mainAxisSize:mainAxisSize.min,
儿童:[
],
),
),
底部导航栏:底部指示器栏(
onTap:(索引)=>{},
项目:项目,,
activeColor:Colors.teal,
不活动颜色:颜色。灰色,
指示颜色:Colors.teal,
),
);
}
}

谢谢,但不考虑使用任何软件包来实现类似的功能,实际上底部的\u indicator\u bar软件包看起来很不错,会尝试这样做不好图标下的文本可能需要分叉回购
bottomNavigationBar: TitledBottomNavigationBar(
  currentIndex: 2, // Use this to update the Bar giving a position
  onTap: (index){
    print("Selected Index: $index");
  },
  items: [
      TitledNavigationBarItem(title: Text('Home'), icon: Icons.home),
      TitledNavigationBarItem(title: Text('Search'), icon: Icons.search),
      TitledNavigationBarItem(title: Text('Bag'), icon: Icons.card_travel),
      TitledNavigationBarItem(title: Text('Orders'), icon: Icons.shopping_cart),
      TitledNavigationBarItem(title: Text('Profile'), icon: Icons.person_outline),
  ]
)
class _HomePageState extends State<HomePage> {
  final List<BottomIndicatorNavigationBarItem> items = [
    BottomIndicatorNavigationBarItem(icon: Icons.home),
    BottomIndicatorNavigationBarItem(icon: Icons.search),
    BottomIndicatorNavigationBarItem(icon: Icons.settings),
  ];


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Indicator Bottom Bar"),
        backgroundColor: Colors.teal,
      ),
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
          ],
        ),
      ),
      bottomNavigationBar: BottomIndicatorBar(
        onTap: (index) => {},
        items: items,
        activeColor: Colors.teal,
        inactiveColor: Colors.grey,
        indicatorColor: Colors.teal,
      ),
    );
  }
}