gpt4 book ai didi

flutter - 如何设置 BottomNavigationBarItem 标签的样式

转载 作者:行者123 更新时间:2023-12-03 13:30:46 26 4
gpt4 key购买 nike

在我的应用程序中,我有一个按钮导航栏。
我正在使用底部导航栏实现多导航,如下所示;
https://medium.com/coding-with-flutter/flutter-case-study-multiple-navigators-with-bottomnavigationbar-90eb6caa6dbf
我把标题文字是这样的。

  BottomNavigationBarItem _buildItem(
{TabItem tabItem, String tabText, IconData iconData}) {
return BottomNavigationBarItem(
icon: Icon(
iconData,
color: widget.currentTab == tabItem
? active_button_color
: Colors.grey,
),
//label: tabText,

title: Text(
tabText,
style: widget.currentTab == tabItem
? Archivo_12_0xff002245
: Archivo_12_grey,
),
);
我收到消息标题已弃用。
当我使用 label 参数时,我该如何设置样式?

最佳答案

您可以使用BottomNavigationBar 上的属性为其设置样式。
示例:

bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'First',
),
BottomNavigationBarItem(
icon: Icon(Icons.exit_to_app),
label: 'Second',
),
],
selectedLabelStyle: TextStyle(fontSize: 22),
selectedItemColor: Colors.red,
),
当然还有更多的属性。检查文档: https://api.flutter.dev/flutter/material/BottomNavigationBar-class.html

关于flutter - 如何设置 BottomNavigationBarItem 标签的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64468586/

26 4 0