どうも、ちょげ(@chogetarou)です。
BottomNavigationBarのアイコンのサイズを設定する方法を紹介します。
方法

BottomNavigationBarのアイコンのサイズを設定するには、引数「iconSize」を使います。
具体的な方法としては、BottomNavigationBarの引数「iconSize」にアイコンのサイズを指定します。
BottomNavigationBar(
iconSize: /*アイコンのサイズ*/,
items: [
・・
],
currentIndex: _currentIndex,
onTap: _onTap,
),
これでBottomNavigationBarのアイコンのサイズを設定することが出来ます。
使用例
以下は、使用例です。
@override
Widget build(BuildContext context) {
return Scaffold(
body: IndexedStack(
index: _currentIndex,
children: [
Container(
child: Text('Settings'),
alignment: Alignment.center,
),
Container(
child: Text('Home'),
alignment: Alignment.center,
color: Colors.yellow,
),
Container(
child: Text('Favorite'),
alignment: Alignment.center,
color: Colors.pink.withOpacity(0.3),
),
],
),
bottomNavigationBar: BottomNavigationBar(
iconSize: 50,
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のアイコンのサイズを設定するには、引数「iconSize」を使います。
コメント