[Flutter]BottomNavigationBarをタイトルテキスト無しにするには?

Flutter

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

BottomNavigationBarをタイトルテキスト無しにする方法を紹介します。

スポンサーリンク

方法

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

BottomNavigationBarをタイトルテキスト無しにするには、BottomNavigationBarの引数「showSelectedLabels」と引数「showUnselectedLabels」を使います。

具体的には、BottomNavigationBarの引数「showSelectedLabels」と引数「showUnselectedLabels」にfalseを指定します。

BottomNavigationBar(
  showSelectedLabels: false,
  showUnselectedLabels: false,
  items: [
    ・・・
  ],
  currentIndex: _currentIndex,
  onTap: _onTap,
),

これでBottomnavigationBarをタイトルテキスト無しにすることが出来ます。

使用例

以下は、使用例です。

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: IndexedStack(
        index: _currentIndex,
        children: _pages,
      ),
      bottomNavigationBar: BottomNavigationBar(
        showSelectedLabels: false,
        showUnselectedLabels: false,
        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,
      ),
    );
  }

まとめ

BottomNavigationbarをタイトルテキスト無しにするには、引数「showSelectedLabels」と引数「showUnselectedLabels」にfalseを指定します。

コメント

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