どうも、ちょげ(@chogetarou)です。
BottomNavigationBarItemの選択されていない時の色を設定する方法を紹介します。
方法

BottomNavigationBarItemの選択されていない時の色を設定するには、BottomNavigationBarの引数「unselectedItemColor」を使います。
具体的な方法としては、BottomNavigationBarの引数「unselectedItemColor」に非選択中の色を指定します。
BottomNavigationBar(
unselectedItemColor: /*選択されていない時の色*/,
items: [
・・・
],
currentIndex: _currentIndex,
onTap: _onTap,
),
これでBottomNavigationBarItemの非選択中の色を設定できます。
使用例
以下は、使用例です。
@override
Widget build(BuildContext context) {
return Scaffold(
body: _pages[_currentIndex],
bottomNavigationBar: BottomNavigationBar(
unselectedItemColor: Colors.black,
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の引数「unselectedItemColor」を使います。
コメント