なにこれ
Flutter で BottomNavigationBar を使ってメニューを作成しようと思ったらテキストが表示されなくて困ったので、その時の解消方法をメモ
事象
解決方法
type: BottomNavigationBarType.fixed
で固定にしないといけないらしい。
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed, // このプロパティを追加する
items: // ...,
)
原因
4つ以上にすると BottomNavigationBarType.shifting
に自動的に切り替わってしまい、テキストが表示されないようになってしまうとのこと。
公式ページ:https://api.flutter.dev/flutter/material/BottomNavigationBar-class.html
The bottom navigation bar's type changes how its items are displayed. If not specified, then it's automatically set to BottomNavigationBarType.fixed when there are less than four items, and BottomNavigationBarType.shifting otherwise.