Skip to main content

Bottom Navigation Title To Label

Summary

#

BottomNavigationBarItem.title gives a deprecation warning, or no longer exists when referenced in code.

Context

#

BottomNavigationBarItems title parameter was deprecated in favor of label. This change was necessary to improve the user experience of BottomNavigationBars when the text scale factor is increased. Items in a BottomNavigationBar now show tooltips on long press. Accomplishing this requires a String parameter on BottomNavigationBarItems.

Description of change

#

The BottomNavigationBarItem class has a title parameter, which is a Widget. This made it impossible for the BottomNavigationBar to show Tooltip widgets, a change that was necessary to improve the accessibility experience. Now, instead of building the BottomNavigationBarItem.title widget, the BottomNavigationBar wraps the BottomNavigationBarItem.label in a Text widget and builds that.

Migration guide

#

Code before migration:

dart
BottomNavigationBarItem(
  icon: Icons.add,
  title: Text('add'),
)

Code after migration:

dart
BottomNavigationBarItem(
  icon: Icons.add,
  label: 'add',
)

Timeline

#

Landed in version: 1.22.0
In stable release: 2.0.0

References

#

API documentation:

Relevant PRs:

  • PR 60655: Clean up hero controller scope
  • PR 59127: Update BottomNavigationBar to show tooltips on long press.

Breaking change proposal: