どうも、ちょげ(@chogetarou)です。
BottomNavigationBarItemのラベルを選択中は、非表示になるようにする方法を紹介します。
方法

BottomNavigationbarItemのラベルを選択中は非表示になるようにするには、BottomNavigationBarの引数「showSelectedLabels」を使います。
具体的には、BottomNavigationBarの引数「showSelectedLabels」にfalseを指定します。
BottomNavigationBar(
showSelectedLabels: false,
items: [
・・・
],
currentIndex: _currentIndex,
onTap: _onTap,
),
これでBottomNavigationBarItemのラベルを選択中は非表示にすることが出来ます。
使用例
以下は、使用例です。
@override
Widget build(BuildContext context) {
return Scaffold(
body: _pages[_currentIndex],
bottomNavigationBar: BottomNavigationBar(
showSelectedLabels: 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,
),
);
}
まとめ
BOttomNavigationbarItemのラベルを選択中は非表示にするには、BottomNavigationBarの引数「showSelectedLabels」を使います。
コメント