如何设置BottomNavigationBarItem标签的样式 [英] How to style BottomNavigationBarItem label

查看:192
本文介绍了如何设置BottomNavigationBarItem标签的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我有一个按钮导航栏.

In my application I have a button navigator bar.

我正在使用底部导航栏实现多重导航,如下所示; https://medium.com/coding-flutter/flutter-case-study-multi-Navigators-with-bottomnavigationbar-90eb6caa6dbf

I am implementing multi navigation with bottom navigation bar as shown here; https://medium.com/coding-with-flutter/flutter-case-study-multiple-navigators-with-bottomnavigationbar-90eb6caa6dbf

我已经输入了标题文字.

I have put the title text like this.

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

我不赞成使用消息标题.

I get message title is deprecated.

当我使用label参数时,该如何设置样式?

When I use the label parameter how do I style it?

推荐答案

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

You style it using properties on the BottomNavigationBar. Example:

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

There are of course more properties. Check the documentation on: https://api.flutter.dev/flutter/material/BottomNavigationBar-class.html

这篇关于如何设置BottomNavigationBarItem标签的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆