[Flutter]選択されているBottomNavationBarItemのテキストのサイズを変えるには?

Flutter

どうも、ちょげ(@chogetarou)です。

選択されているBottomNavigationBarItemのテキストのサイズを変える方法を紹介します。

スポンサーリンク

方法

インターフェース, インターネット, プログラム, ブラウザ, Www

選択されているBottomNavigationBarItemのテキストのサイズを変えるには、BottomNavigationBarの引数「selectedFontSize」を使います。

具体的には、BottomNavigationBarの引数「selectedFontSize」に選択されている時のテキストのサイズを指定します。

BottomNavigationBar(
  selectedFontSize: /*選択されている時のテキストのサイズ*/,
  items: [
    ・・・
  ],
  currentIndex: _currentIndex,
  onTap: _onTap,
),

これで選択されているBottomNavigationBarItemのテキストのサイズを変えることが出来ます。

使用例

以下は、使用例です。

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _pages[_currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        selectedFontSize: 30,
        items: [
          BottomNavigationBarItem(
            icon: Icon(Icons.settings),
            label: 'Settings',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.home),
            label: 'Home',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.favorite),
            label: 'Favorite',
          ),
        ],
        currentIndex: _currentIndex,
        onTap: _onTap,
      ),
    );
  }

まとめ

選択されているBottomNavigationBarIteimのテキストのサイズを変えるには、BottomNavigationBarの引数「selectedFontSize」を使います。

コメント

タイトルとURLをコピーしました