LoginSignup
0
0

Flutter の BottomNavigationBar で4つのアイテムを設定するとテキストが表示されない問題の解決方法

Last updated at Posted at 2024-04-28

なにこれ

Flutter で BottomNavigationBar を使ってメニューを作成しようと思ったらテキストが表示されなくて困ったので、その時の解消方法をメモ

事象

3つまでだとこのように良い感じに表示されるが
image.png

4つ以上になるとテキストが見えなくなった!
image.png

解決方法

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.

image.png

そして…

無事に直った!よかったよかった
image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0